es-shims / Date

ES spec-compliant `Date` shim/polyfill/replacement that works as far down as ES3
MIT License
3 stars 3 forks source link

72 unit tests now fail when running tests-only in Node 20-22 #3

Open jdalton opened 1 month ago

jdalton commented 1 month ago

72 unit tests now fail when running tests-only in Node 20-22.

Related to https://github.com/es-shims/Date/blob/v2.0.5/test/Date/tests.js#L216

st.match(i + ':' + date.getSeconds(), new RegExp(i + ':(?:' + 59 + '|' + 1 + ')'))

If changed to

st.match(i + ':' + date.getSeconds(), new RegExp(i + ':(?:' + 57 + '|' + 1 + ')'))

all the tests then pass

ljharb commented 1 month ago

I'm not seeing that in node v22.9.0 or v20.17.0. Is there a chance it's OS-dependent, or that they're flaky?

jdalton commented 1 month ago

Hmm on my v22.9.0 (via nvm) with the latest main branch. I still see it. I'm on MacOS Sonoma 14.6.1.

ljharb commented 1 month ago

Perhaps it's the Mac OS; I'm on 14.6.1 now (and probably wasn't before), and i get 144 failures all being off by a ms or so. I'm also in a very different timezone than I was last week, which may factor in.

The UTC time it's ran may matter too - in particular, I've often run into time bugs during the daily window where the local timezone and UTC timezone are on different dates.

ljharb commented 1 month ago

I've narrowed down the failures I'm seeing right now to:

# is an invalid date
not ok 1 2012-11-31T23:59:59.000Z is an invalid date
  ---
    operator: equal
    expected: NaN
    actual:   1354406399000
    at: <anonymous> ($PWD/test/Date.parse/tests.js:24:7)
    stack: |-
      Error: 2012-11-31T23:59:59.000Z is an invalid date
          at Test.assert [as _assert] ($PWD/node_modules/tape/lib/test.js:492:48)
          at Test.strictEqual ($PWD/node_modules/tape/lib/test.js:670:7)
          at $PWD/test/Date.parse/tests.js:24:7
          at forEachArray ($PWD/node_modules/for-each/index.js:12:17)
          at forEach ($PWD/node_modules/for-each/index.js:54:9)
          at Test.<anonymous> ($PWD/test/Date.parse/tests.js:23:3)
          at Test.run ($PWD/node_modules/tape/lib/test.js:126:28)
          at Test._end ($PWD/node_modules/tape/lib/test.js:398:5)
          at Test.end ($PWD/node_modules/tape/lib/test.js:211:7)
          at Test.<anonymous> ($PWD/test/Date.parse/builtin.js:10:4)
  ...
not ok 13 2011-02-29T12:00:00.000Z is an invalid date
  ---
    operator: equal
    expected: NaN
    actual:   1298980800000
    at: <anonymous> ($PWD/test/Date.parse/tests.js:24:7)
    stack: |-
      Error: 2011-02-29T12:00:00.000Z is an invalid date
          at Test.assert [as _assert] ($PWD/node_modules/tape/lib/test.js:492:48)
          at Test.strictEqual ($PWD/node_modules/tape/lib/test.js:670:7)
          at $PWD/test/Date.parse/tests.js:24:7
          at forEachArray ($PWD/node_modules/for-each/index.js:12:17)
          at forEach ($PWD/node_modules/for-each/index.js:54:9)
          at Test.<anonymous> ($PWD/test/Date.parse/tests.js:23:3)
          at Test.run ($PWD/node_modules/tape/lib/test.js:126:28)
          at Test._end ($PWD/node_modules/tape/lib/test.js:398:5)
          at Test.end ($PWD/node_modules/tape/lib/test.js:211:7)
          at Test.<anonymous> ($PWD/test/Date.parse/builtin.js:10:4)
  ...

The builtin failures I think are already covered in polyfill, but the implementation failures are tricky because I think it's important to confirm whether these failures are due to web reality/es5-shim/es6-shim tests, or due to the spec.