Skip to content

Commit

Permalink
fix: toStrictEqual didn't have an assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 29, 2021
1 parent 149c123 commit fc9524b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions packages/vitest/src/integrations/chai/jest-expect.ts
Expand Up @@ -82,8 +82,8 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
asymmetricEquals(actual, expected),
'not match with #{exp}',
'should not match with #{exp}',
actual,
expected,
actual,
)
}
else {
Expand All @@ -97,11 +97,25 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
})

def('toStrictEqual', function(expected) {
return (
iterableEquality(this, expected)
?? typeEquality(this, expected)
?? sparseArrayEquality(this, expected)
?? arrayBufferEquality(this, expected)
const obj = utils.flag(this, 'object')
const equal = asymmetricEquals(
obj,
expected,
[
iterableEquality,
typeEquality,
sparseArrayEquality,
arrayBufferEquality,
],
true,
)

return this.assert(
equal,
'expected #{this} to strictly equal #{exp}',
'expected #{this} to not strictly equal #{exp}',
expected,
obj,
)
})
def('toBe', function(expected) {
Expand Down
2 changes: 1 addition & 1 deletion test/core/test/jest-expect.test.ts
Expand Up @@ -87,8 +87,8 @@ describe('jest-expect', () => {

it('object', () => {
expect({}).toEqual({})
expect({}).toStrictEqual({})
expect({}).not.toBe({})
expect({}).not.toStrictEqual({})

const foo = {}
const complex = { foo: 1, bar: { foo: 'foo', bar: 100, arr: ['first', { zoo: 'monkey' }] } }
Expand Down

0 comments on commit fc9524b

Please sign in to comment.