Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"mocha-trx-reporter" throwing error as "TypeError: Cannot read property 'start' of undefined"" #18

Closed
gadepallavi opened this issue Apr 22, 2020 · 5 comments

Comments

@gadepallavi
Copy link

I am trying to use "mocha-trx-reporter" to generate the ".trx" file for my E2E tests. I installed the "mocha-trx-reporter" latest version which is "^3.2.3". After installing when I tried to run the tests it is showing error as "TypeError: Cannot read property 'start' of undefined" in file "\node_modules\mocha-trx-reporter\lib\trx.js" line 83

@pmoleri
Copy link
Contributor

pmoleri commented Apr 23, 2020

Hi @gadepallavi your error points to a missing "stats" property but I can't find the root cause for that. Could you describe your setup?
node, npm and mocha versions?

@gadepallavi
Copy link
Author

Hello, please find the requested infomration below:

Versions:
node: v12.16.1
npm: 6.14.3
mocha: ^5.2.0

Describe the steps:

  1. Installed the mocha-trx-reporter version (^3.2.3)
  2. Updated the script to use the mocha-trx-reporter as display below:
    "npm run build && mocha --reporter mocha-trx-reporter --reporter-options output=./TestResults/test-result.trx Output/**/*.test.js"
  3. After adding above statement, when I run my E2E tests it, chrome broweser launch and it executes the tests, however at the end of the test gives me mentioned error as "TypeError: Cannot read property 'start' of undefined" in file "\node_modules\mocha-trx-reporter\lib\trx.js" line 83" and I dont see the ".trx" file generated for it.

Please let me know if you need any details.

Regards,
Pallavi

@pmoleri
Copy link
Contributor

pmoleri commented Apr 23, 2020

Thanks for the info. I think that the problem is a mismatch between the mocha version included in mocha-trx-reporter and your project's mocha version.

Now I changed mocha dependency to be a peer-dependency, which I think it's the correct approach. With this change the reporter will work with your mocha version instead of bundling its own.

It's not yet published to npm, you can try the fix by installing it from github:

npm install "github:Infragistics/mocha-trx-reporter#23b98b433ad11dd70b05ef265f4d989afa95637a"

Please let me know if this works for you.

@gadepallavi
Copy link
Author

Hello,

I tried the fix using the commands given and it is working for me. Thank you. Please let me know when it is available on NPM and I will make the necessary changes on my end.

Regards,
Pallavi

@pmoleri
Copy link
Contributor

pmoleri commented Apr 27, 2020

The fixed version has been published to npm, you can now install it as standard dep:
npm install --save-dev mocha-trx-reporter@3.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants