I am starting to work with protractor using jasmine, but I am instantly getting an 'unexpected token' error when it parses my config that uses arrow an arrow function. Does anyone know what I might be missing? Dependency? It's on a new macbook.I didn't have this problem on my old pc.
exports.config = {
framework: 'jasmine2',
capabilities: env.capabilities,
baseUrl: env.baseUrl,
specs: env.specs,
allScriptsTimeout: 30 * 10000,
onPrepare: async () => {
if (!global.jasmineRequire) {
var jasmineRequire = require('jasmine-core');
if (typeof jasmineRequire.interface !== 'function') {
throw "not able to load real jasmineRequire"
}
global.jasmineRequire = jasmineRequire;
}
require('jasmine-promises'); await browser.get(env.baseUrl +
'#!/login');
macs-iMac:e2etest AchieveIt$ protractor conf.js
[08:03:45] E/configParser - Error code: 105
[08:03:45] E/configParser - Error message: failed loading
configuration file conf.js
[08:03:45] E/configParser -
/Users/mac/achieveit/E2ETests/e2etest/conf.js:13
onPrepare: async ()=> {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
UPDATE UPDATE
Never mind, I see you're using an object now. What is your compiler? I think your compiler is not compiling the es6 correctly. Make sure you have all your node modules installed correctly whether it's globally or locally. Your code should be valid, see this fiddle: https://es6console.com/j20jir0j/
UPDATE
Even in es6, you syntax is wrong. It should be:
onPrepare = async () => {
OLD for TS
That's not valid typescript and shouldn't work anywhere.
Change your line to:
onPrepare = (): async => {
Or if you don't need lexical scope:
onPrepare(): async {