Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump sinon from 17.0.1 to 19.0.2 #6302

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"msw-storybook-addon": "~2.0.3",
"nock": "~13.5.1",
"selfsigned": "~2.4.1",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"storybook": "~7.6.11",
"storybook-react-i18next": "~2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-classifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"react": "~18.2.0",
"react-dom": "~18.2.0",
"rosie": "~2.1.0",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"snazzy": "~9.0.0",
"storybook": "~7.6.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ describe('ClassificationQueue', function () {
})

describe('keeps classifications in localStorage if backend fails', function () {
let clock

before(function () {
clock = sinon.useFakeTimers({ global })
sinon.stub(global, 'setTimeout').callsFake(() => 100)
Copy link
Contributor

@eatyourgreens eatyourgreens Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've changed the return type of setTimeout here. My mistake, setTimeout returns an integer, not a timeout.

This should really mock setTimeout with a function that creates a mock timeout object and returns its ID. Then clearTimeout should destroy the mock timeout for a given ID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fake Timers is useful here because it will take care of that mocking for you.

https://github.com/sinonjs/fake-timers#api-reference

sinon.stub(global, 'clearTimeout')
Copy link
Contributor

@goplayoutside3 goplayoutside3 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eatyourgreens the use of sinon.useFakeTimers() was added in #3019. I'm not totally sure of the difference between .setFakeTimers() vs .stub(global) here, but reverting to .stub() allows the tests to pass. Any thoughts on this sinon method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the release notes for 19, they’ve upgraded Fake Timers to the latest version.

sinonjs/sinon#2612

Do you know what the classification queue tests are using the fake clock for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for fake timers are here but, as noted, it’s just a thin wrapper for the Fake Timers package. These docs do explain config.global.

https://sinonjs.org/releases/latest/fake-timers/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With your change, the tests run using the local clock ie. the clock continues to tick during the tests. With fake timers, I think the test clock doesn’t tick unless you tell it to tick.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test now looks like it’s evergreen to me, because timeouts can’t be set by the mocks. If there were bugs in the timeout code, I think the mocks might hide them.

it('should not set a timer to retry failed classifications', async function () {
expect(classificationQueue.flushTimeout).to.be.null()
await classificationQueue.add(classificationData)
expect(classificationQueue.flushTimeout).to.be.null()
})

Copy link
Contributor

@eatyourgreens eatyourgreens Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this should mock clearTimeout with a function that takes a timeout and clears it.

By turning off timeouts, you've turned off retries in the classification queue. That's potentially a problem because the tests check whether or not a retry has been scheduled for a given response.

})

after(function () {
clock.restore()
global.setTimeout.restore()
global.clearTimeout.restore()
})

beforeEach(function () {
Expand Down Expand Up @@ -166,14 +166,14 @@ describe('ClassificationQueue', function () {
})

describe('with invalid classifications', function () {
let clock

before(function () {
clock = sinon.useFakeTimers({ global })
sinon.stub(global, 'setTimeout').callsFake(() => 100)
sinon.stub(global, 'clearTimeout')
})

after(function () {
clock.restore()
global.setTimeout.restore()
global.clearTimeout.restore()
})

beforeEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"eslint-plugin-jsx-a11y": "~6.10.1",
"jsdom": "~25.0.1",
"mocha": "~10.8.2",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"storybook": "~7.6.11",
"storybook-react-i18next": "~2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-panoptes-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"mocha": "~10.8.2",
"mock-local-storage": "~1.1.19",
"nock": "~13.5.1",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"snazzy": "~9.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"mocha": "~10.8.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"snazzy": "~9.0.0",
"storybook": "~7.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-subject-viewers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"chai-dom": "~1.12.0",
"dirty-chai": "~2.0.1",
"mocha": "~10.8.2",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"storybook": "~7.6.11",
"watch": "^1.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"nock": "~13.5.4",
"process": "~0.11.10",
"prop-types": "^15.8.1",
"sinon": "~17.0.0",
"sinon": "~19.0.2",
"sinon-chai": "~3.7.0",
"snazzy": "~9.0.0",
"storybook": "~7.6.11",
Expand Down
112 changes: 54 additions & 58 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3597,47 +3597,33 @@
dependencies:
"@sindresorhus/fnv1a" "^1.2.0"

"@sinonjs/commons@^2.0.0":
version "2.0.0"
resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz"
integrity sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^3.0.0":
version "3.0.0"
resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz"
integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==
"@sinonjs/commons@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd"
integrity sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==
dependencies:
type-detect "4.0.8"

"@sinonjs/fake-timers@^10.0.2":
version "10.3.0"
resolved "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz"
integrity sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==
dependencies:
"@sinonjs/commons" "^3.0.0"

"@sinonjs/fake-timers@^11.2.2":
version "11.2.2"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz#50063cc3574f4a27bd8453180a04171c85cc9699"
integrity sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==
"@sinonjs/fake-timers@^13.0.1", "@sinonjs/fake-timers@^13.0.2":
version "13.0.5"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-13.0.5.tgz#36b9dbc21ad5546486ea9173d6bea063eb1717d5"
integrity sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw==
dependencies:
"@sinonjs/commons" "^3.0.0"
"@sinonjs/commons" "^3.0.1"

"@sinonjs/samsam@^8.0.0":
version "8.0.0"
resolved "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.0.tgz"
integrity sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==
"@sinonjs/samsam@^8.0.1":
version "8.0.2"
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-8.0.2.tgz#e4386bf668ff36c95949e55a38dc5f5892fc2689"
integrity sha512-v46t/fwnhejRSFTGqbpn9u+LQ9xJDse10gNnPgAcxgdoCDMXj/G2asWAC/8Qs+BAZDicX+MNZouXT1A7c83kVw==
dependencies:
"@sinonjs/commons" "^2.0.0"
"@sinonjs/commons" "^3.0.1"
lodash.get "^4.4.2"
type-detect "^4.0.8"
type-detect "^4.1.0"

"@sinonjs/text-encoding@^0.7.1":
version "0.7.2"
resolved "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz"
integrity sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==
"@sinonjs/text-encoding@^0.7.3":
version "0.7.3"
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.3.tgz#282046f03e886e352b2d5f5da5eb755e01457f3f"
integrity sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==

"@socket.io/component-emitter@~3.1.0":
version "3.1.0"
Expand Down Expand Up @@ -8586,11 +8572,16 @@ diff-sequences@^29.6.3:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921"
integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==

diff@^5.1.0, diff@^5.2.0:
diff@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.2.0.tgz#26ded047cd1179b78b9537d5ef725503ce1ae531"
integrity sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==

diff@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-7.0.0.tgz#3fb34d387cd76d803f6eebea67b921dab0182a9a"
integrity sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==

diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
Expand Down Expand Up @@ -12362,10 +12353,10 @@ just-diff@^6.0.0:
resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-6.0.2.tgz#03b65908543ac0521caf6d8eb85035f7d27ea285"
integrity sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==

just-extend@^4.0.2:
version "4.2.1"
resolved "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz"
integrity sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==
just-extend@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-6.2.0.tgz#b816abfb3d67ee860482e7401564672558163947"
integrity sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==

keyv@^4.5.3:
version "4.5.4"
Expand Down Expand Up @@ -13666,16 +13657,16 @@ next@~14.2.7:
"@next/swc-win32-ia32-msvc" "14.2.17"
"@next/swc-win32-x64-msvc" "14.2.17"

nise@^5.1.5:
version "5.1.5"
resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.5.tgz#f2aef9536280b6c18940e32ba1fbdc770b8964ee"
integrity sha512-VJuPIfUFaXNRzETTQEEItTOP8Y171ijr+JLq42wHes3DiryR8vT+1TXQW/Rx8JNUhyYYWyIvjXTU6dOhJcs9Nw==
nise@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/nise/-/nise-6.1.1.tgz#78ea93cc49be122e44cb7c8fdf597b0e8778b64a"
integrity sha512-aMSAzLVY7LyeM60gvBS423nBmIPP+Wy7St7hsb+8/fc1HmeoHJfLO8CKse4u3BtOZvQLJghYPI2i/1WZrEj5/g==
dependencies:
"@sinonjs/commons" "^2.0.0"
"@sinonjs/fake-timers" "^10.0.2"
"@sinonjs/text-encoding" "^0.7.1"
just-extend "^4.0.2"
path-to-regexp "^1.7.0"
"@sinonjs/commons" "^3.0.1"
"@sinonjs/fake-timers" "^13.0.1"
"@sinonjs/text-encoding" "^0.7.3"
just-extend "^6.2.0"
path-to-regexp "^8.1.0"

no-case@^3.0.4:
version "3.0.4"
Expand Down Expand Up @@ -14744,7 +14735,7 @@ path-to-regexp@0.1.10:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b"
integrity sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==

path-to-regexp@^1.0.0, path-to-regexp@^1.7.0:
path-to-regexp@^1.0.0:
version "1.8.0"
resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz"
integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
Expand All @@ -14756,6 +14747,11 @@ path-to-regexp@^6.3.0:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.3.0.tgz#2b6a26a337737a8e1416f9272ed0766b1c0389f4"
integrity sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==

path-to-regexp@^8.1.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-8.2.0.tgz#73990cc29e57a3ff2a0d914095156df5db79e8b4"
integrity sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==

path-type@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz"
Expand Down Expand Up @@ -16621,16 +16617,16 @@ sinon-chai@~3.7.0:
resolved "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz"
integrity sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==

sinon@~17.0.0:
version "17.0.1"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-17.0.1.tgz#26b8ef719261bf8df43f925924cccc96748e407a"
integrity sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g==
sinon@~19.0.2:
version "19.0.2"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-19.0.2.tgz#944cf771d22236aa84fc1ab70ce5bffc3a215dad"
integrity sha512-euuToqM+PjO4UgXeLETsfQiuoyPXlqFezr6YZDFwHR3t4qaX0fZUe1MfPMznTL5f8BWrVS89KduLdMUsxFCO6g==
dependencies:
"@sinonjs/commons" "^3.0.0"
"@sinonjs/fake-timers" "^11.2.2"
"@sinonjs/samsam" "^8.0.0"
diff "^5.1.0"
nise "^5.1.5"
"@sinonjs/commons" "^3.0.1"
"@sinonjs/fake-timers" "^13.0.2"
"@sinonjs/samsam" "^8.0.1"
diff "^7.0.0"
nise "^6.1.1"
supports-color "^7.2.0"

sirv@^2.0.3:
Expand Down Expand Up @@ -17757,7 +17753,7 @@ type-detect@4.0.8:
resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==

type-detect@^4.0.0, type-detect@^4.0.8, type-detect@^4.1.0:
type-detect@^4.0.0, type-detect@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.1.0.tgz#deb2453e8f08dcae7ae98c626b13dddb0155906c"
integrity sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==
Expand Down
Loading