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

Cannot read property 'duration' of undefined #49

Closed
jahilldev opened this issue Feb 19, 2019 · 13 comments
Closed

Cannot read property 'duration' of undefined #49

jahilldev opened this issue Feb 19, 2019 · 13 comments

Comments

@jahilldev
Copy link

I've just noticed the following error being thrown when running our client side tests in TeamCity:

[12:50:27][Step 3/4] Cannot read property 'duration' of undefined
[12:50:27]
[Step 3/4] TypeError: Cannot read property 'duration' of undefined
    at Runner.<anonymous> (node_modules\mocha-teamcity-reporter\lib\teamcity.js:127:52)
[12:50:27][Step 3/4] C:\BuildAgent\work\2d7908fc7e0f07c9\WhiteLabelFrontEndTests\node_modules\mocha-teamcity-reporter\lib\teamcity.js:127
[12:50:27][Step 3/4] 		log(formatString(SUITE_END, 'mocha.suite', stats.duration, flowId));

Nothing's changed with the setup or package versions.

Any idea why the stats object would be undefined and what might be causing this?
We're using version 2.4.0.

Many thanks

@yairhaimo
Copy link

This is because mocha 6 was released:
mochajs/mocha@42303e2

@njumbo
Copy link

njumbo commented Feb 19, 2019

Hey dear contributors, on our side we also needed to remove the reporter because of this issue. Is there a way to refer to a version of mocha that is lower than 6.0 so we can keep using the reporter? :)

Thanks

@jamie-sherriff
Copy link
Collaborator

Hey all, i will have a look into this but i suspect it might be mochajs/mocha#2819

@jhdevuk Could you please get me a simplified version of your test that breaks? so i can add it to my own test suite so i know what i am doing will solve your issue as i don't have any existing tests that do break like that with mocha 6.

@njumbo you should be able to lock your package.json/package-lock.json to mocha@5 like so

  "dependencies": {
    "mocha": "^5.2.0"
  },

or do a npm install like

npm install mocha@5

@shahata
Copy link

shahata commented Feb 21, 2019

Locking package.json will not help, it will only work when manually fiddling with package-lock.json. Anyway, I think it is not a good idea that this package depends on mocha. It should be in peerDependencies instead, which would mean that people would have bumped into this issue when they upgrade to mocha@6 instead of everyone getting it the moment it was released.

@jamie-sherriff
Copy link
Collaborator

jamie-sherriff commented Feb 21, 2019

@shahata ah thanks good point! my only concern would be it could be a breaking change for someone who is relying on the reporter to install mocha for them. I think ill do a major version bump

@roymiloh
Copy link

@jamie-sherriff maybe >=3.5.0 <6 for mocha?

@jamie-sherriff
Copy link
Collaborator

@roymiloh was thinking that but i already have a workaround for mocha 6 i was thinking of doing the following then:

  1. Restrict the mocha dependency version to less than 6 and publish that as a patch version
  2. followed by a major version bump to support mocha 6 and make it a peer dependency

if anyone has any other suggestions please let me know as ill start doing that now.

@jamie-sherriff
Copy link
Collaborator

Restrict the mocha dependency version to less than 6 and publish that as a patch version has been released as 2.5.2

@roymiloh
Copy link

Thanks, looks good.

@jamie-sherriff
Copy link
Collaborator

Mocha version 6 support is published under the tag next
mocha-teamcity-reporter@next
please let me know if you encounter any issues.

@njumbo
Copy link

njumbo commented Feb 21, 2019

Thanks @jamie-sherriff, we don't have a package-lock right now, this change will help us in the meantime. we will try it out today.

@jahilldev
Copy link
Author

@jamie-sherriff Amazing, thanks

@jamie-sherriff
Copy link
Collaborator

Fixed in 3.0.0 release

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

6 participants