Execute Shell Commands on Startup
TestCafe can execute shell commands on startup. Use this capability to launch a local web server or deploy your app. After the test run ends, TestCafe automatically terminates the process you initiated.
Pass the shell command to the -a (--app) CLI option or the runner.startApp Test Runner method.
testcafe chrome ./my-tests/ --app "node server.js"
await runner
.browsers('chrome')
.src('./my-tests/')
.startApp('node server.js')
.run();
Related configuration file property: appCommand
Shell Command Timeout
TestCafe delays tests to allow the shell command to execute. The default timeout is 1000 milliseconds. Use the --app-init-delay CLI flag or a runner.startApp parameter to specify the timeout value.
testcafe chrome ./my-tests/ --app "node server.js" --app-init-delay 4000
await runner
.browsers('chrome')
.src('./my-tests/')
.startApp('node server.js', 4000)
.run();
Related configuration file property: appInitDelay