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

refactor(test): Mocha DSL for event tests #1928

Merged
merged 3 commits into from Feb 22, 2020

Conversation

mastermatt
Copy link
Member

No description provided.

nock('http://example.test')
.get('/')
.reply(418)

const assertion = function(req) {
nock.emitter.on('no match', req => {
expect(req.path).to.equal('/definitelymaybe')
nock.emitter.removeAllListeners('no match')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be moved into an afterEach?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved removeAllListeners to the global afterEach. I seemed like it belongs there.

nock.disableNetConnect()
nock.emitter.on('no match', function(req) {

nock.emitter.on('no match', req => {
expect(req.hostname).to.equal('example.test')
nock.emitter.removeAllListeners('no match')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@mastermatt mastermatt merged commit 9375dcd into nock:master Feb 22, 2020
@mastermatt mastermatt deleted the 1305/events/mocha branch February 22, 2020 18:10
@github-actions
Copy link

github-actions bot commented Mar 1, 2020

🎉 This PR is included in version 12.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants