Closed micellius closed 10 years ago
Have you tried process.env in the child?
I am actually passing env to the child https://github.com/kof/node-qunit/blob/master/lib/testrunner.js#L66
If it doesn't work, any ideas?
I have seen that you pass process.env
in the child process, but it does not contain command line arguments out of the box, so I utilised this existing mechanism and submitted PR #106 to resolve the issue with minimum changes.
If I understand correctly the documentation, passed env object should be accessible in the child as it is in the parent, no?
Oh its process.argv, not process.env.argv ...
I have a better solution for this. Now you can use process.argv in the child.
check it out, reopen if something is wrong.
Yes, you understand correctly: passed env
is accessible in the child as in the parent, however in order to receive command line arguments of parent process you need process.argv
or something that is called args
in cli.js
. Since cli.js
passes to test runner only limited set of arguments it is familiar with (code, tests, deps and log), other arguments are lost and are not propagated further and therefore not accessible via process.argv
or process.env
of the child process. To solve this, I placed process.argv
arguments one by one into process.env
(which is already accessible in the child process) with qunit.args.
prefix.
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 ownprocess.argv
). This issue may be solved by propagating command line arguments (passed to cli.js) to child processes viaprocess.env
and 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_value
syntax.