Closed fungus1487 closed 5 years ago
I just came across this issue today and I came to the same conclusion as fungus1487. For a little more context I believe in my case it was because I am using jsdom instead of phantomjs
Ah yep I can see how this is a problem. Could someone provide a simple end to end example pulling in mocha webpack and this reporter for me?
I ran into this issue after setting up a new project using the Vue.js CLI.
@jamie-sherriff - I put together a simple vue client that reproduces it for you. https://github.com/lreading/mocha-webpack-with-teamcity-reporter
Run the following:
You'll get the error noted above.
In case you happen to notice... I had to specify node_modules/mocha-teamcity-reporter
because there's a separate issue with the mocha-webpack plugin with finding reporters, not at all related to this project.
@lreading Awesome thanks for the easy example, i will take a look it.
@lreading Sorry for the delay. Have published a workaround in the branch fix-mocha-webpack
Can install using npm install travisjeffery/mocha-teamcity-reporter#fix-mocha-webpack)
it works on your sample so hopefully solves your problem?
With phantomjs now being deprecated i am tempted to remove the specific logic for it but will probably have to wait for a major version bump.
@jamie-sherriff - Works great! Thanks for taking this on!
I think it'd be wise to wait for the next major version bump, as there's likely some co-dependencies hanging around in some projects.
Unless you need it for anything else, I'll probably remove that git repo I set up to reproduce.
Thanks again! :tada:
No problem! @lreading thanks for your help as well now closing and released under 2.5.1
The specific line https://github.com/travisjeffery/mocha-teamcity-reporter/blob/master/lib/teamcity.js#L18 decides whether to pull the reporters base from mocha import or phantomjs. When running tests inside
mocha-webpack
(e.g. using Vue.js) the reporter fails withcannot resolve module require('./base')
The fix should be in the test
typeof window === 'undefined'
to check if the environment being run in ismocha-webpack
and if so simply use the first part of the if statement thus assuming mocha.Currently I have simply copied the code into our project and replaced:
with
This will work as a fix for us but an actual fix to support mocha-webpack would be greatly appreciated and open up this tools use to vue.js projects on 2.0+