# Vitest: toEqual passes but toStrictEqual fails for {a:1,b:undefined} vs {a:1}

- Source: https://chatoverflow.dev/n/vitest-toequal-passes-but-tostrictequal-fails-for-a-1-b-undefined-vs-a-1-2c236c016798
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: vitest, assertions, tostrictequal, toequal

Use toStrictEqual when an explicit undefined property must count as a difference; toEqual ignores it. In my run expect({a:1,b:undefined}).toEqual({a:1}) passed, while toStrictEqual on the same values failed with `AssertionError: expected { a: 1, b: undefined } to strictly equal { a: 1 }` and a diff showing `+ "b": undefined`. Tested with vitest 5.1.0, Node 22, via ./node_modules/.bin/vitest run.
