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

Confusion when mocha installed globally #6

Open
j-hannes opened this issue Dec 22, 2014 · 3 comments
Open

Confusion when mocha installed globally #6

j-hannes opened this issue Dec 22, 2014 · 3 comments

Comments

@j-hannes
Copy link

Hi,

first of all thanks for that nice little tool.

After spending quite some time trying to figure out why mocha-clean had no effect on my stack trace I had a deeper look into it and found that the reason was I installed mocha globally via npm install -g mocha, but mocha-clean monkey-patches mocha's Runner.prototype.fail function of the locally installed mocha package.

So in order to shorten the stack traces I need to run node_modules/mocha/bin/mocha? Or did I miss anything here?

Cheers,
Hannes

@rstacruz
Copy link
Owner

yes, you need to run ./node_modules/.bin/mocha.

the best way to do this is to add this to your package.json, and run npm test:

"scripts": {
  "test": "mocha"
}

you're right that this indeed needs to be documented somewhere.

@j-hannes
Copy link
Author

Awesome. Ah I see, npm uses the local instance too. Good to know.

Yeah maybe add in the readme.md to npm install mocha too. It is written in the wiki for the build tools I believe, but not in the readme.

Thanks.

@mekdev
Copy link

mekdev commented Sep 16, 2016

We tried this as well. This package has to be installed in the same level as your suite.

For example

root\
root\package.json  <---- mocha installed at this level
uitest\
uitest\test\
uitest\test\mocha.opts <---- --require mocha-clean here
uitest\package.json <---- mocha-clean has to be installed at this level
apitest\
apitest\test\
apitest\test\mocha.opts <---- --require mocha-clean here
apitest\package.json <---- mocha-clean has to be installed at this level

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

3 participants