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

test: Improve tests for header matching with function; adopt new promise-rejection assertion #1481

Merged
merged 5 commits into from
Mar 26, 2019

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Mar 23, 2019

  1. Assert the expected argument is passed. (It's the correct argument, though not the expected type!)
  2. When the function returns true, assert the request matches.
  3. When the function returns false, assert the request doesn't match.
  4. When the function returns false, assert the mock is not consumed.
  5. I added copies of these tests for matchHeader called on the interceptor instead of the scope.

Test 4 uncovered an unexpected behavior in tap, which is that t.rejects causes our afterEach hook to fire – since it's implemented as a subtest.

Not knowing how to work around this, I replaced our uses of t.rejects with a promise-rejection assertion that does not rely on a subtest.

Ref: #1305 (comment) and tapjs/tapjs#525

This was prompted by #1480, however this isn't related to that bug (which so far I can't reproduce).

…nction

1. Assert the expected argument is passed. (It's the correct argument,
   though not the expected type!)
2. When the function returns true, assert the request matches.
3. When the function returns false, assert the request doesn't match.
4. When the function returns false, assert the mock is not consumed.
   (This test is failing, which is a bug.
Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Great!

@gr2m
Copy link
Member

gr2m commented Mar 25, 2019

merge at your convenience, I’m not 100% sure if you want to add to it

@paulmelnikow
Copy link
Member Author

Yea, thanks, let's merge it.

@paulmelnikow paulmelnikow merged commit 75cceb6 into beta Mar 26, 2019
@paulmelnikow paulmelnikow deleted the test-header-matching branch March 26, 2019 01:10
@nockbot
Copy link
Collaborator

nockbot commented Apr 12, 2019

🎉 This PR is included in version 11.0.0-beta.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 13, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this pull request Sep 4, 2019
…ise-rejection assertion (#1481)

1. Assert the expected argument is passed. (It's the correct argument, though not the expected type!)
2. When the function returns true, assert the request matches.
3. When the function returns false, assert the request doesn't match.
4. When the function returns false, assert the mock is not consumed.
5. I added copies of these tests for `matchHeader` called on the interceptor instead of the scope.

Test 4 uncovered an unexpected behavior in tap, which is that `t.rejects` causes our `afterEach` hook to fire – since it's implemented as a subtest.

Not knowing how to work around this, I replaced our uses of `t.rejects` with a promise-rejection assertion that does not rely on a subtest.

Ref: #1305 (comment) and tapjs/tapjs#525
gr2m pushed a commit that referenced this pull request Sep 4, 2019
…ise-rejection assertion (#1481)

1. Assert the expected argument is passed. (It's the correct argument, though not the expected type!)
2. When the function returns true, assert the request matches.
3. When the function returns false, assert the request doesn't match.
4. When the function returns false, assert the mock is not consumed.
5. I added copies of these tests for `matchHeader` called on the interceptor instead of the scope.

Test 4 uncovered an unexpected behavior in tap, which is that `t.rejects` causes our `afterEach` hook to fire – since it's implemented as a subtest.

Not knowing how to work around this, I replaced our uses of `t.rejects` with a promise-rejection assertion that does not rely on a subtest.

Ref: #1305 (comment) and tapjs/tapjs#525
gr2m pushed a commit that referenced this pull request Sep 5, 2019
…ise-rejection assertion (#1481)

1. Assert the expected argument is passed. (It's the correct argument, though not the expected type!)
2. When the function returns true, assert the request matches.
3. When the function returns false, assert the request doesn't match.
4. When the function returns false, assert the mock is not consumed.
5. I added copies of these tests for `matchHeader` called on the interceptor instead of the scope.

Test 4 uncovered an unexpected behavior in tap, which is that `t.rejects` causes our `afterEach` hook to fire – since it's implemented as a subtest.

Not knowing how to work around this, I replaced our uses of `t.rejects` with a promise-rejection assertion that does not rely on a subtest.

Ref: #1305 (comment) and tapjs/tapjs#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants