Giter Club home page Giter Club logo

Comments (18)

SeriousM avatar SeriousM commented on September 4, 2024

did you tried to workaround with the excludePending option?

from mocha-trx-reporter.

jessehouwing avatar jessehouwing commented on September 4, 2024

from mocha-trx-reporter.

WizX20 avatar WizX20 commented on September 4, 2024

Same issue here
2019-09-02T18:44:17.1637752Z TypeError: test.isPending is not a function 2019-09-02T18:44:17.1639484Z at testResults.tests.forEach (E:\agents\myagent-test-0\_work\r2\a\TESTS\release\node_modules\mocha-trx-reporter\lib\trx.js:92:22) 2019-09-02T18:44:17.1641447Z at Array.forEach (<anonymous>:null:null) 2019-09-02T18:44:17.1643429Z at Runner.ReporterTrx.runner.on (E:\agents\myagent-test-0\_work\r2\a\TESTS\release\node_modules\mocha-trx-reporter\lib\trx.js:91:27) 2019-09-02T18:44:17.1646632Z at emitOne (events.js:121:20) 2019-09-02T18:44:17.1649120Z at Runner.emit (events.js:211:7) 2019-09-02T18:44:17.1652497Z at Reporter.emit (C:\Users\myagent-test\AppData\Local\Cypress\Cache\3.3.1\Cypress\resources\app\packages\server\lib\reporter.js:239:55) 2019-09-02T18:44:17.1656527Z at Object.server.startWebsockets.onMocha (C:\Users\myagent-test\AppData\Local\Cypress\Cache\3.3.1\Cypress\resources\app\packages\server\lib\project.js:298:22) 2019-09-02T18:44:17.1659438Z at Socket.<anonymous> (C:\Users\myagent-test\AppData\Local\Cypress\Cache\3.3.1\Cypress\resources\app\packages\server\lib\socket.js:235:36) 2019-09-02T18:44:17.1662081Z at emitTwo (events.js:126:13) 2019-09-02T18:44:17.1665662Z at Socket.emit (events.js:214:7) 2019-09-02T18:44:17.1668360Z at C:\Users\myagent-test\AppData\Local\Cypress\Cache\3.3.1\Cypress\resources\app\packages\socket\node_modules\socket.io\lib\socket.js:503:12 2019-09-02T18:44:17.1671679Z at _combinedTickCallback (internal/process/next_tick.js:131:7) 2019-09-02T18:44:17.1678187Z at process._tickCallback (internal/process/next_tick.js:180:9)

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

It seems that Cypress uses its own version of Mocha, instead of picking up the project's version: cypress-io/cypress#4652 and the version that Cypress includes doesn't have the isPending() method.

Some reporters are implemented using only events while other like XUnit and mocha-trx-reporter are implemented using the isPending() method.

So, this could be solved by Cypress or by changing the way these reporters are implemented to not rely on Runnable.isPending() method. I'd prefer the former, but I would accept a pull request that changes this reporter to prevent this issue.

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

Update: mocha-trx-reporter was also bringing in its own mocha version, perhaps that was part of the issue too. This was changed in v3.2.4 so perhaps this new version behaves properly even with Cypress.

Closing the issue now.

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

@pmoleri I still have the same issue in mocha-trx-reporter version 3.2.4.
Is there a workaround for it?
Is there a specific version of mocha that we have to use with cypress & cypress-multi-reporters& mocha-trx-reporter?

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

@smarandav mocha-trx-reporter relies in Runnable.isPending() method that was introduced in [email protected] 4 years ago.

I think you need to either:

  • Update to a Cypress version that uses a more recent version of Mocha.
    (you probably can check the version that Cypress is using by looking for mocha in your package-lock.json)
  • Find a way to monkey patch the Runnable class to add the missing method.
    You can probably do this by requiring a local setup file in your https://mochajs.org/#mochaopts

If you choose to monkey patch to fix this issue, I can't tell you if some other issues will appear.

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

@pmoleri thanks for your help

I have doubled checked and I am using latest version of mocha in both my packages that need it (cypress-multi-reporters, mocha-trx-reporter).

When installing those two ^^ I do not have a hardcoded mocha dependency as per package-lock.json but still it complains about not finding the isPending() method.
"cypress-multi-reporters": {
"version": "1.4.0",
"resolved": "http://packages.je-labs.com/npm/private-npm/cypress-multi-reporters/-/cypress-multi-reporters-1.4.0.tgz",
"integrity": "sha1-Xx0EhKIJWc/ngvG/Za0Wxq2ATac=",
"dev": true,
"requires": {
"debug": "^4.1.1",
"lodash": "^4.17.15"
},

"mocha-trx-reporter": {
"version": "3.2.4",
"resolved": "http://packages.je-labs.com/npm/private-npm/mocha-trx-reporter/-/mocha-trx-reporter-3.2.4.tgz",
"integrity": "sha512-hY4rHfzl49TgmgfkkgCskQIiOmi8J8h+/XcuPNz3y5HtdebD7uOKY6o+7LZVB/xg+3zfwmJ+weXqpinnVsJ5kA==",
"dev": true,
"requires": {
"node-trx": "^0.9.1"
}
}

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

@pmoleri I am looking at the mocha repo and I can see that isPending has '@Private' attribute vs the skip one for instance which has an explicit definition as @public & @memberof Mocha.Runnable?

https://github.com/mochajs/mocha/blob/cb5eb8ed42abfd0d63c5013353843f1208ff6582/lib/runnable.js#L142

vs

https://github.com/mochajs/mocha/blob/cb5eb8ed42abfd0d63c5013353843f1208ff6582/lib/runnable.js#L132

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

I am looking at the mocha repo and I can see that isPending has '@Private' attribute vs the skip one for instance which has an explicit definition as @public & @memberof Mocha.Runnable?

I see what you mean. Although the official XUnit reporter also uses this method.
It seems that there's no clear official way to get the pending state of a test.

I have doubled checked and I am using latest version of mocha in both my packages that need it (cypress-multi-reporters, mocha-trx-reporter).

Don't you also have cypress as a dependency? Have you tried updated this one?
Could you check the actual resolved version of mocha? Just look for occurrences of "mocha": { in your package-lock.json.

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

I am looking at the mocha repo and I can see that isPending has '@Private' attribute vs the skip one for instance which has an explicit definition as @public & @memberof Mocha.Runnable?

I see what you mean. Although the official XUnit reporter also uses this method.
It seems that there's no clear official way to get the pending state of a test.

I think xUnit reporter is failing with the same error!

I have doubled checked and I am using latest version of mocha in both my packages that need it (cypress-multi-reporters, mocha-trx-reporter).

Don't you also have cypress as a dependency? Have you tried updated this one?
Could you check the actual resolved version of mocha? Just look for occurrences of "mocha": { in your package-lock.json.

Cypress does not depend on mocha at all, only those two packages I mentioned above do and I do not have any hardcoded dependency of mocha in my package-lock.json file.

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

Cypress does not depend on mocha at all, only those two packages I mentioned above do and I do not have any hardcoded dependency of mocha in my package-lock.json file.

Ok, I was assuming it was, I dont know anything about Cypress. However, someone should be requiring Mocha beacuse it's a peerDependency in both [email protected] and [email protected], that means that both reporters rely on someone else requiring mocha => 3.1.2.

You could try npm install --save-dev mocha@latest, but my understanding from issue cypress-io/cypress#4652 is that Cypress is in fact bringing its own mocha version (a pretty old one).

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

ok, thanks for looking into it.
My issue is with latest version of mocha and the error I have is in the mocha-trx-reporter here)

TypeError: test.isPending is not a function
at C:\source\RestaurantClaimsWeb\node_modules\mocha-trx-reporter\lib\trx.js:92:22
at Array.forEach (:null:null)
at Runner. (C:\source\RestaurantClaimsWeb\node_modules\mocha-trx-reporter\lib\trx.js:91:27)
at Runner.emit (events.js:208:15)
at Reporter.emit (C:\Users\AppData\Local\Cypress\Cache\3.8.3\Cypress\resources\app\packages\server\lib\reporter.js:234:55)
at Object.onMocha (C:\Users\AppData\Local\Cypress\Cache\3.8.3\Cypress\resources\app\packages\server\lib\project.js:359:18)
at Socket. (C:\Users\AppData\Local\Cypress\Cache\3.8.3\Cypress\resources\app\packages\server\lib\socket.js:303:32)
at Socket.emit (events.js:203:13)
at C:\Users\AppData\Local\Cypress\Cache\3.8.3\Cypress\resources\app\packages\socket\node_modules\socket.io\lib\socket.js:528:12
at processTicksAndRejections (internal/process/task_queues.js:75:11)

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

And my question is: does that isPending() method gets exposed outside the Runnable class in mocha as I can see it has the '@Private' attribute

https://github.com/mochajs/mocha/blob/cb5eb8ed42abfd0d63c5013353843f1208ff6582/lib/runnable.js#L142

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

And my question is: does that isPending() method gets exposed outside the Runnable class in mocha as I can see it has the '@Private' attribute.

Yes JS doesn't have a real notion of private methods, that's only a documentation annotation.
Everything works fine when not used in Cypress.

BTW, this is the mocha dependency on [email protected]. I don't know what version are you running. Could you try updating to Cypress >=4.5.0?

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

I have "cypress": "^4.7.0",

from mocha-trx-reporter.

smarandav avatar smarandav commented on September 4, 2024

but I do have another package that has hardcoded cypress dependency,

"@vue/cli-plugin-e2e-cypress": {
"version": "4.4.1",
"resolved": "http://packages.je-labs.com/npm/private-npm/@vue/cli-plugin-e2e-cypress/-/cli-plugin-e2e-cypress-4.4.1.tgz",
"integrity": "sha1-n2zA7YJDrVc6nzMZzyQ7MI7F07A=",
"dev": true,
"requires": {
"@vue/cli-shared-utils": "^4.4.1",
"cypress": "^3.8.3",
"eslint-plugin-cypress": "^2.10.3"
},

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

Well, that's really confusing now. From what I've seen Cypress 4.7.0 is using a modern mocha version, even if you have that other dependency I don't think it should be an issue.
Somehow, Cypress is getting in the way and something that works directly with Mocha fails when running from Cypess.
I can only suggest you to fork the project and tweak it in a way that doesn't rely on isPending() method.

Anyway, I do recommend you to put mocha@^7.0.0 as a top dependency in your project. Why? Because both reporters depend on it, and when they do require("mocha") they will get an unknown version that may be incompatible with them. And 7.x should be compatible with Cypress 4.7.

from mocha-trx-reporter.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.