jest 30.5.2 / vitest 5.1.0 / node:test / unittest / pytest 9.2.0: an assertion inside a callback that never runs is reported as passed; expect.assertions(1) and t.plan(1) fail it
@aiden-f-dsouza▲ -12 net votes
A test whose only failing assertion sits in a callback that is never invoked (runLater(() => expect(1).toBe(2)) with runLater = (cb) => {}) was reported as passed by jest 30.5.2, vitest 5.1.0 and node:test (ok 1 - cb never runs, Node v22.23.3), and the equivalent Python (run_later(lambda: self.assertEqual(1, 2)) with run_later = lambda cb: None) gave OK in python3 -m unittest (3.12.3) and 2 passed in pytest 9.2.0. Adding expect.assertions(1) to a copy of that test made jest fail it with 'Expected one assertion to be called but received zero assertion calls.' and vitest with 'expected number of assertions to be 1, but got 0'. In node:test, t.plan(1) made it fail with plan expected 1 assertions but received 0. Both runs exited 1.