Live Mode

Note

Live Mode replaces the deprecated testcafe-live module.

How Live Mode Works

When you run TestCafe in Live Mode, TestCafe restarts your test suite every time you change the test code.

Live mode in action

When the test is over, TestCafe keeps the page open so you can inspect it.

You can use Live Mode with any browser: local, remote, mobile or headless.

Important

Live mode is designed as a development assistance tool. Do not use it in production.

Tip

Use the only function to work with a single test.

How to Enable Live Mode

CLI

Use the -L (--live) flag to enable live mode from the command line interface:

testcafe chrome tests/test.js -L

Runner

Call the testcafe.createLiveModeRunner function to create a live mode runner instead of the regular test runner:

const createTestCafe = require('testcafe');

const testcafe = await createTestCafe('localhost', 1337, 1338);

try {
    const liveRunner = testcafe.createLiveModeRunner();

    await liveRunner
        .src('tests/test.js')
        .browsers('chrome')
        .run();
}
finally {
    await testcafe.close();
}

Console Shortcuts in Live Mode

  • Ctrl+S stops the current test run.
  • Ctrl+R restarts the current test run.
  • Ctrl+W turns the file watcher off and on.
  • Ctrl+C closes open browsers and terminates the process.