CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

mocha_factory.js is returning an error

Open marciolou78 opened this issue 8 years ago • 11 comments

What are you trying to achieve?

I'm just have tried to run my steps using a "mochawesome" to generate the reports.

What do you get instead?

SyntaxError: Unexpected token )

Provide console output if related. Use --verbose mode for more details.

codeceptjs run --steps --reporter mochawesome

E:\Java\SasWebCodecept\node_modules\codeceptjs\lib\mocha_factory.js:41
      );
      ^

SyntaxError: Unexpected token )
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (E:\Java\SasWebCodecept\node_modules\codeceptjs\lib\container.js:4:22)

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

Provide test source code if related

// paste test

Details

  • CodeceptJS version: ^1.0.3
  • NodeJS Version: v8.2.1
  • Operating System: Windows 10 Professional
  • Protractor || WebDriverIO || Nightmare version (if related) : "webdriverio": "^4.9.11"
  • Configuration file:

My solution for this !

Just change the version on package.json unfortunately now I need to use the "codeceptjs":"1.0.2"

marciolou78 avatar Dec 21 '17 13:12 marciolou78

I'm getting the same issue with : Node v7.6.0 CodeceptJS v1.0.3 and v1.0.2 (tried both)

daniellevautier avatar Jan 03 '18 13:01 daniellevautier

@XDevelopers & @daniellevautier - I have had the same issue with Node v6.9.5 on macOS. After updating to the last stable version of Node (v9.2.1), I am not experiencing this issue anymore.

TonnyGaric avatar Jan 03 '18 16:01 TonnyGaric

Thank you

In my case I've just get the previous version from Codecept and works to me...

marciolou78 avatar Jan 03 '18 20:01 marciolou78

This happens because your node version should be at least 8.9+ I had the same problem and after updating all works good.

andreluizbnu avatar Jan 09 '18 13:01 andreluizbnu

@XDevelopers which codecept version did you roll back to?

loganbeougher avatar Jan 16 '18 19:01 loganbeougher

Can you retry with v1.1.1 and with at least Node 8.9+?

I've been running it on MacOS and Win 7 with no problems.

reubenmiller avatar Jan 19 '18 17:01 reubenmiller

Following fix worked for me. you better try. Open node_modules\codeceptjs-nightmare\node_modules\codeceptjs\lib\mocha_factory.js in text editor. There is an additional comma in line 41. Remove it. attributes, <-- here Enjoy.!!!

chathurangamdk avatar Jan 26 '18 09:01 chathurangamdk

Funny enough the call to Object.defineProperty works fine with a trailing comma with Node 8.9.3 (at least from the command prompt in node). So maybe there is a deference in processing the function between the older node versions.

Did you manage to upgrade node as well? Or did you just remove the trailing comma?

reubenmiller avatar Jan 26 '18 11:01 reubenmiller

@chathurangamdk thanks for pointing out. removing trailing comma worked.

kishlayk avatar Feb 09 '18 06:02 kishlayk

This is not longer a problem when using Node 8.9.1 or above. And CodeceptJS ≥V1.1.0 only supports Node ≥8.9.1. So I'll close this issue.

reubenmiller avatar Feb 17 '18 09:02 reubenmiller

This is issue related to NodeJS version... I resolved mine after updating to latest node (v10.6.0)

peteroravec avatar Jul 13 '18 14:07 peteroravec