Access Environment Variables in Tests

Set Environment Variables

Use the export command to create an environment variable on macOS and Linux:

export DEV_MODE=true
testcafe chrome test.js

On Windows, use the set command:

set DEV_MODE=true
testcafe chrome test.js

For more information on how to set environment variables, see this answer on StackExchange.

Access Environment Variables

Use the process.env property to access environment variables in test code:

fixture `My Fixture`;

test('Print an Environment Variable', async t => {
    console.log('Development mode: ', process.env.DEV_MODE);
});