There was an error while starting the test runner:
/root/projects/test/test/e2e/specs/test.js:1
(function (exports, require, module, __filename, __dirname) { import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
Using the following inside an end to end test will break the test suite:
JSON.stringify({})
It appears that the e2e tests are missing BABEL_ENV=test or a transformation plugin.
e2e simply starts a dev server for the tests backend.
The webpack config should transpile no matter which env you've set (or not set).
Feels ugly but works for me:
var JSON = require('babel-runtime/core-js/json/stringify')
Adding BABEL_ENV=test to the e2e task of package.json as follows worked for me...
package.json
...
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"e2e": "BABEL_ENV=test node test/e2e/runner.js",
...
I digged a little deeper and found that BABEL_ENV supports a fallback the points to NODE_ENV which seems intended to be used. But in .babelrc the configured env is called test and the e2e runner.js defines process.env.NODE_ENV = 'testing'.
I added the missing env testing to .babelrc as it does not need the istanbul plugin which gets loaded in test env for the unit tests.
{
"env":
"testing": {
"presets": ["env", "stage-2"]
}
}
}
Additionally I removed the first line require('babel-register') in nightwatch.conf.js and now it works as expected.
Hey, thanks for digging into this!
We should definitely fix this in the template. Will get to it when I find time - maybe we can ref actor these test / testing RMV variables into one.
In #1178 I consolidate the test & testing env variables into test, that should solve this problem once it's merged
@LinusBorg looking forward to it
Most helpful comment
Adding BABEL_ENV=test to the e2e task of package.json as follows worked for me...
package.json