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


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 ``;

test('My test', async t => {
    await t
        .setNativeDialogHandler(() => true);

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.

Inspect Page in Google Chrome

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.

Debugging in Chrome Dev Tools