Debug Tests in Chrome Developer Tools
This topic describes how to debug TestCafe test code in Chrome Developer Tools.
Add the --inspect-brk
CLI flag to the test execution command to run TestCafe in Node.js debug mode.
testcafe --inspect-brk chrome ./tests
Note
The standard TestCafe debug mode does not allow you to debug selectors. To enable this functionality, use the --experimental-debug CLI flag.
Put the debugger
keyword in test code where you want to stop.
fixture `My fixture`
.page `https://devexpress.github.io/testcafe/example`;
test('My test', async t => {
debugger;
await t
.setNativeDialogHandler(() => true);
.click('#populate')
.click('#submit-button');
});
Open the Chrome inspector (chrome://inspect
) and find the TestCafe Node.js debug process in the Remote Target. Click Inspect to invoke the debugger with your test code.
Chrome invokes its Developer Tools and the debugger stops test execution at the first line. Click the Resume script execution button or press F5 to continue. Test execution pauses at each breakpoint or debugger
keyword in test code.