I want to use Node native support for import/export with NPM packages. To start I'm running cuccumberjs version 3.1.0. However when I run this command:
/usr/local/bin/node --experimental-modules ./node_modules/.bin/cucumber-js
I get an error:
(node:42011) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: Unexpected token import
/full/path/to/test/directory/features/support/getWindowLocation.js:2
import {runJsInBrowser} from "./runJsInBrowser.mjs";
^^^^^^
All my automation test run fine until I try to convert one of my scripts to a ES module and import it. Here is an snippet from the file:
runJsInBrowsers.mjs
export default async function runJsInBrowser(
browserDriver,
windowFunc,
waitForReturn = true,
timeOut = 10000
) {
...
};
--
package.json
{
"name": "tests",
"version": "0.0.1",
"description": "Test for testing.",
"main": "index.js",
"license": "UNLICENSED",
"dependencies": {
"chromedriver": "^2.0",
"cucumber": "^3.1",
"selenium-webdriver": "^3.0"
},
"devDependencies": {
}
}