There is no direct way to set an array as an environment variable. It is better to store all arrays in a
.config file and set a flag as an environment variable to specify which array should be used in a test. Please take a look at the answer regarding environment variables in our FAQ topic.
Yet, you can definitely parse the string as shown in the following examples.
- With the
testcafe chrome test.js --env="[\"foo\", \"bar\"]"
import minimist from 'minimist';
const args = minimist(process.argv.slice(2));
const environment = JSON.parse(args.env);
testcafe chrome test.js
const STRING = process.env.DEV_MODE.split(';');