lucono/karma-test-explorer

Configuring tests with more node memory

Closed this issue · 2 comments

Hi,
Whilst running tests I get out of heap memory errors. These can be averted by replacing ng test on the command line with

To replicate in the Karma test explorer I have tried setting the below. When changing this setting the tests fail to run with an error

Failed to load tests - Karma server failed to start: spawn node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng test ENOENT

I presume that this is a file path error of some description. Is there any guidance as to how (where from( the path should be constructed and how to do this.

"karmaTestExplorer.angularProcessCommand": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng test"

Thanks

lucono commented

The karmaTestExplorer.angularProcessCommand setting is what you need, but should only be given a single command or script file. It will not work if set to a command + argument combination.

So in this case you should create a small script file which launches node with all the relevant arguments you need, and then set angularProcessCommand to the path of that script file. The extension will replace the node in the regular test launch command with your script (ie, as if it were the node command), and pass it all the other arguments that it would otherwise pass to node for the test.

So the script needs to be able to accept arguments and call node with those arguments while also adding the additional memory arguments that you need.

Usually, this can be a simple #!/bin/bash or #!/usr/bin/env node or other type of script.

lucono commented

Feel free to reopen if still an issue.