Is it possible to use both in e2e tests? I can use both in Vue. Those js files are in myproject/src/js folder. But in myproject/test/e2e, I know that Nightwatch use node which can only use require
syntax, but I can rename the file to mjs, which then support import
syntax, but if I try to import mjs file in my other test by using require
, it gives Error: Must use import to load ES Module
error....I am wondering if this is possible. Just like what I can use in my Vue src/*, where js files have mixed use of require/import everywhere.
I have tried some presets in babel.config.js
module.exports = {
presets: [
["@babel/preset-env"],
// I tried below as well
[
"@vue/cli-plugin-babel/preset",
{
useBuiltIns: "entry",
}
],
]
}
I have those babel dependencies in package.json
devDependencies {
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
}
In nightwatch.conf.js
require('babel-register')() // no differences if i add this or not..
module.exports = {
presets: [
["es2015", {"modules": false}] // set modules to true or false dose not help..
]
}
I have been struggling with this for days...please help me..