sinonjs / fake-timers

Fake setTimeout and friends (collectively known as "timers"). Useful in your JavaScript tests. Extracted from Sinon.JS
BSD 3-Clause "New" or "Revised" License
794 stars 103 forks source link

Test suite is not runnable in Node >= 16: Performance is not defined #427

Closed fatso83 closed 2 years ago

fatso83 commented 2 years ago

What did you expect to happen? npm test should run successfully

What actually happens

  365 passing (356ms)
  6 pending
  3 failing

  1) FakeTimers
       stubTimers
         should let performance.mark still be callable after FakeTimers.install() (#136):
     AssertionError: [refute.exception] Expected not to throw but threw TypeError (global.performance.mark is not a function)
      at Object.fail (node_modules/@sinonjs/referee/lib/create-fail.js:5:25)
      at Object.fail (node_modules/@sinonjs/referee/lib/define-assertion.js:44:25)
      at assertion (node_modules/@sinonjs/referee/lib/define-assertion.js:62:17)
      at Function.referee.<computed>.<computed> [as exception] (node_modules/@sinonjs/referee/lib/define-assertion.js:89:26)
      at Context.<anonymous> (test/fake-timers-test.js:3731:28)
      at processImmediate (node:internal/timers:464:21)

  2) FakeTimers
       stubTimers
         should not alter the global performance properties and methods:
     ReferenceError: Performance is not defined
      at Context.<anonymous> (test/fake-timers-test.js:3740:17)
      at processImmediate (node:internal/timers:464:21)

  3) FakeTimers
       stubTimers
         should replace the getEntries, getEntriesByX methods with noops that return []:
     ReferenceError: Performance is not defined
      at Context.<anonymous> (test/fake-timers-test.js:3762:17)
      at processImmediate (node:internal/timers:464:21)

How to reproduce

# install Node 16, here using the `n` version manager
$ n 16

$ npm i; npm test
SimenB commented 2 years ago

Not fixed by #412?

fatso83 commented 2 years ago

Indeed it is. So strange. Must be some random black hole of time where my git repo was morphed into some old version. Also called not pulling in latest changes (but I must have done that, which makes everything even stranger). Oh well.