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 hook to auto register should #693

Closed
wotsyula opened this issue May 1, 2016 · 4 comments
Closed

Mocha hook to auto register should #693

wotsyula opened this issue May 1, 2016 · 4 comments

Comments

@wotsyula
Copy link

wotsyula commented May 1, 2016

Would be nice if there was a hook script to allow me to automatically load chai.should(). Something like:

mocha --require chai/register-should, chai-as-promised/should, sinon-chai/should

And have them automatically added for testing without the need to use require("chai").should() and chai.use(...)

I'd do it myself but it needs a register-should.js file stored in the chai node_modules directory.

@meeber
Copy link
Contributor

meeber commented May 1, 2016

@wotsyula thanks for posting!

The good news is that starting with the next version -r chai/should will properly register should per #604. However, it won't go any further by creating a global chai variable or anything like that.

The way I approach this situation currently is to create a test bootstrap file that performs the preparatory tasks, and then require that via -r test/bootstrap.

@wotsyula
Copy link
Author

wotsyula commented May 2, 2016

@meeber Thanks for the quick reply.

Good to hear. I'm gonna close this now. Before I do, I think chai/should is too vague. There should be at least some kind of verb. If your gonna go with bootstrap then chai/bootsrap-should would be less ambiguous. Personally my vote is for chai/register-should

@wotsyula wotsyula closed this as completed May 2, 2016
@keithamus
Copy link
Member

@wotsyula you could also make an npm module called chai-register-should which just contained global.should = require('chai').should().

@inancgumus
Copy link

Hey guys. I've added a pull request for expect here: #868

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

4 participants