Using node-qunit for integration tests scenarios requires passing configuration options via command line to tests (like back-end host, etc.). Since test runner spawns new processes (child.js), process.argv of the parent process is no longer available in tests (because each spawened process has it's own process.argv). This issue may be solved by propagating command line arguments (passed to cli.js) to child processes via process.env and used as follows:
shell
$ ./node_modules/qunit/bin/cli.js -c src/code.js -t test/test.js --host test.domain.com
test.js
var host = process.env['qunit.args.host']; // <-- will be "test.domain.com"
For example jasmine-node allows to propagate command line arguments passed to cli.js using --config argument_name argument_value syntax.
Using
node-qunitfor integration tests scenarios requires passing configuration options via command line to tests (like back-end host, etc.). Since test runner spawns new processes (child.js),process.argvof the parent process is no longer available in tests (because each spawened process has it's ownprocess.argv). This issue may be solved by propagating command line arguments (passed to cli.js) to child processes viaprocess.envand used as follows:shell
test.js
For example jasmine-node allows to propagate command line arguments passed to cli.js using
--config argument_name argument_valuesyntax.