Skip to content

Commit

Permalink
Reset assertionCalls to zero so that our hack doesn't interfere with …
Browse files Browse the repository at this point in the history
…existing expect.assertions() usage
  • Loading branch information
timkindberg committed Oct 28, 2021
1 parent 5497e5f commit 3a27d0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/when.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ expect.extend({
})
expect().__capture_equals__()
let JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object')
// Hackily reset assertionCalls back to zero incase dev's tests are using expect.assertions()
global[JEST_MATCHERS_OBJECT].state.assertionCalls = 0
// Hackily delete the custom matcher that we added
delete global[JEST_MATCHERS_OBJECT].matchers.__capture_equals__
/**
* End hack
Expand Down
4 changes: 4 additions & 0 deletions src/when.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -821,5 +821,9 @@ describe('When', () => {
expect(fn(1)).toEqual('a') // fails and will still return 'b' (as before my change)
expect(fn(2)).toEqual('b')
})

it('does not add to the number of assertion calls', () => {
expect.assertions(0)
})
})
})

0 comments on commit 3a27d0b

Please sign in to comment.