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

Bump sinon to ^15.2.0 #37430

Merged
merged 3 commits into from
Jun 27, 2023
Merged

Bump sinon to ^15.2.0 #37430

merged 3 commits into from
Jun 27, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented May 28, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
sinon (source) ^15.0.4 -> ^15.2.0 age adoption passing confidence

Release Notes

sinonjs/sinon

v15.2.0

Compare Source

  • 66b0081e
    Use fake-timers v10.1.0 re-released as v10.3.0 (Carl-Erik Kopseng)

    Version 10.2.0 of fake-timers had an unexpected breaking
    change. We re-released 10.1.0 as 10.3.0 to force users
    into jumping over the deprecated version.

    v10.2.0 was re-released as v11.0.0 and will be part of
    the next Sinon major

  • a79ccaeb
    Support callable instances (#​2517) (bojavou)
    • Support callable instances

    • Clean prettier lint


    Co-authored-by: - <->

  • d220c995
    fix: bundling compatibility with webpack@5 (#​2519) (Avi Vahl)
    • fix: bundling compatibility with webpack@5

    when using webpack v5 to bundle code that calls require('sinon') (cjs) , it would have defaulted to "exports->require" and fail with multiple node-api requirements (util, timers, etc.)

    this patch ensures that anyone who bundles sinon for browser gets the (browser-compatible) esm version.

    tested on both webpack v5 and v4. should be noted that v4 worked even without this patch, as it automatically injected polyfills. v5 no longer does so. with this PR, people using webpack@4 to bundle sinon at least see size improvement, as the polyfills are no longer required.

    • fix: revert change for package.json -> "browser"

    browserify doesn't seem to like esm. leave that entry point alone, and ensure "exports" -> "browser" (which webpack@5 uses) is esm.

Released by Carl-Erik Kopseng on 2023-06-20.

v15.1.2

Compare Source

  • 02b73aed
    Update lock file after removing node_modules ... (Carl-Erik Kopseng)

Released by Carl-Erik Kopseng on 2023-06-12.

v15.1.1

Compare Source

  • 194fc2ef
    Change fake-timers version to specifically target the one containing the 'jump' feature (Carl-Erik Kopseng)

    Instead of the later (breaking) version. See #​470

  • 05f05ac3
    docs: Remove threw(obj) from docs (#​2513) (Morgan Roderick)

    Since the introduction of threw in

    0feec9f, no one have reported that

    threw(obj) doesn't work as the documentation states.

    const sinon = require("sinon");
    
    const o = { pie: "apple" };
    
    const f = sinon.fake.throws(o);
    
    f();
    
    // this is supposed to return true
    
    f.threw(o);
    
    // => false

    Since it has been 12+ years without an error report, it's safe to assume

    that no one uses the threw method in this way. Let's remove it from

    the documentation.

Released by Carl-Erik Kopseng on 2023-06-12.

v15.1.0

Compare Source

  • 79e719f2
    Ensure we use a fake-timers version with clock.jump (Carl-Erik Kopseng)
  • b2a4df5a
    Add docs for clock.jump method (#​2512) (Jason O'Neill)
  • f096abff
    fix (#​2514): only force new or inherited descriptors to be configurable (#​2515) (Carl-Erik Kopseng)

Released by Carl-Erik Kopseng on 2023-05-18.


Configuration

📅 Schedule: Branch creation - "on sunday before 6:00am" in timezone UTC, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Update of dependencies label May 28, 2023
@mui-bot
Copy link

mui-bot commented May 28, 2023

Netlify deploy preview

https://deploy-preview-37430--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 374f644

@DiegoAndai DiegoAndai self-assigned this May 31, 2023
@DiegoAndai DiegoAndai self-requested a review May 31, 2023 14:06
@DiegoAndai DiegoAndai added the on hold There is a blocker, we need to wait label May 31, 2023
@DiegoAndai
Copy link
Member

The failing test is this Tooltip followCursor test, which is timing out. Investigating.

@DiegoAndai
Copy link
Member

Update: The issue is coming from @sinonjs/fake-timers@10.2.0. The test passes with @sinonjs/sinon@15.1.0 and @sinonjs/fake-timers@1.1.0, which is the version before 1.2.0. I think this change broke it but don't know why yet.

cc: @mui/core looking at the change I'm suspicious about, does something catch your attention as the reason why it broke the Tooltip test?

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Jun 7, 2023

looking at the change I'm suspicious about, does something catch your attention as the reason why it broke the Tooltip test?

I couldn't find a clear explanation or solution for the issue. However, based on my investigation, I observed that the test passes when run on the browser environment, but fails when run on JSDom, which is a testing environment that simulates Node.js.

Also I see the stack trace pointing to the following lines in Node.js timers module:

      at listOnTimeout (internal/timers.js:557:17)
      at processTimers (internal/timers.js:500:7)

They added mocks to the timers module in in sinonjs/fake-timers#467 (v10.2.0).

Since the same problem is also blocking a pull request in the MUI X repository (mui/mui-x#9063), it might be worth opening an issue in the fake-timers repository (https://github.com/sinonjs/fake-timers/issues) to seek further assistance and resolution for this issue.

@fatso83
Copy link

fatso83 commented Jun 12, 2023

Sinon maintainer here. Since you are not using fake timers directly I followed the rendering utils suspects in
https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Tooltip/Tooltip.test.js#L4.

In https://github.com/mui/material-ui/blob/master/test/utils/createRenderer.tsx#L18 the fake timers are setup, nothing scary that I can see.

I am guessing this is basically a case of JSOM's timers and Node's timers fighting it out (window.setTimeout vs global.setTimeout). You can see what I think is a similar issue here: jestjs/jest#625

Figuring out exactly which line needs to be changed, if it is the setup (changing the target for the stubbing from the implicit global to window), if it is the client code that should be calling window.setTimeout or the test util that should somehow be changed I am not immediately sure.

We did not expect this to break uses of fake-timers, so we can see if we should retract (deprecate) this minor version and re-release it as a new major version to avoid this. Ditto for sinon.


I don't have the possibility to debug the details right now, but could you try to pinpoint which sets of timers (global.setTimeout vs window.setTimeout) is being stubbed and which should have been stubbed, etc.? And maybe see if choosing an explicit target to fake the clock for could be a thing? Alternatively, add global.setTimeout = window.setTimeout or some variations thereof. Would be nice to know if it can be worked around (which we could document) or if it needs a new flag (nodeBuiltins: false).

@renovate renovate bot changed the title Bump sinon to ^15.1.0 Bump sinon to ^15.1.1 Jun 12, 2023
@fatso83
Copy link

fatso83 commented Jun 12, 2023

This should pass if changing to use Sinon 15.1.2 (which targets the older version). Still, would like to know if the above section could point out what is wrong.

While I could reproduce locally by running yarn test:unit, I was not able to run the single test suite, as it would fail all tests in that file when run separately with the same error:

  MUI: The `anchorEl` prop provided to the component is invalid.
The anchor element should be part of the document layout.
Make sure the element is present in the document or that it's not display none.

Stack:
    at /home/carlerik/code/material-ui/packages/mui-base/src/Popper/Popper.tsx:155:19
    at commitHookEffectListMount (/home/carlerik/code/material-ui/node_modules/react-dom/cjs/react-dom.development.js:23150:26)

No idea why. Used

$ yarn mocha --config .mocharc.js /home/carlerik/code/material-ui/packages/mui-material/src/Tooltip/Tooltip.test.js
  .!!.!.!.!..!.!.!.!..!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.......!.!.!.!.!.!.!.!.!.!,,,..!.!.......!.!...!.!...!..!.!.!.!.!........!...!.!.!.!.!.!....!.!.!..^C

@renovate renovate bot changed the title Bump sinon to ^15.1.1 Bump sinon to ^15.1.2 Jun 12, 2023
@DiegoAndai
Copy link
Member

@fatso83 thanks for taking a look into it!

I think updating to sinon 15.1.2 is not working as that version uses fake-timers version ^10.1.0, so it's being bumped to 10.2.0, the latest minor, which has the issue. Either releasing a 10.3.0 version that reverts the timers mock or marking fake-timers version as ~10.1.0 might work, whatever makes more sense.

I tried all the variations of global.setTimeout = window.setTimeout that I could think of but nothing worked. If there's something else I can try to help debugging please let me know. Maybe it's another method that's causing the issue.

To run the test locally, you can use yarn test:unit --grep Tooltip. That will run only the Tooltip tests. You can also use it.only on the test to run only the failing case:

describe('prop: followCursor', () => {
    it.only('should use the position of the mouse', async function test() {
      // ...

@fatso83
Copy link

fatso83 commented Jun 20, 2023

Hopefully re-releasing 10.1.0 as 10.3.0 will fix this for you guys. I have no idea why the changes did not work for you guys, though, but this will probably give you some more time. https://www.npmjs.com/package/@sinonjs/fake-timers?activeTab=versions

@renovate renovate bot changed the title Bump sinon to ^15.1.2 Bump sinon to ^15.2.0 Jun 20, 2023
@fatso83
Copy link

fatso83 commented Jun 22, 2023

The new failure is related to Webpack 5 adjustments we just merged in Sinon 15.2. You probably need to change your polyfills setup.

Similar: microsoft/PowerBI-visuals-tools#365

@renovate
Copy link
Contributor Author

renovate bot commented Jun 27, 2023

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

Warning: custom changes will be lost.

@DiegoAndai DiegoAndai requested review from michaldudak and removed request for DiegoAndai June 27, 2023 13:48
@DiegoAndai
Copy link
Member

Hey @michaldudak, may I ask for your review here? required a slight change in the regression's test webpack config: https://github.com/mui/material-ui/pull/37430/files#diff-c6283f5fa0c0e1715f4d0fdac062964728ebcd04b2868febd6efa5b1b4017600R28

@michaldudak
Copy link
Member

All seems to be good with regression tests - good job!

@michaldudak michaldudak merged commit 4729014 into master Jun 27, 2023
18 checks passed
@michaldudak michaldudak deleted the renovate/sinon-15.x branch June 27, 2023 18:13
@DiegoAndai
Copy link
Member

Thanks @fatso83 for taking a look into it and helping us update! 🚀

@fatso83
Copy link

fatso83 commented Jun 29, 2023

No worries, glad to help. that still leaves the mystery of what originally breaks your tests. As soon as we release Sinon 16 with fake-timers 11 this will resurface. Hopefully someone is able to create a trimmed-down minimal testcase by then.

whitphx added a commit to whitphx/vscode-emacs-mcx that referenced this pull request Aug 15, 2023
whitphx added a commit to whitphx/vscode-emacs-mcx that referenced this pull request Aug 15, 2023
whitphx added a commit to whitphx/vscode-emacs-mcx that referenced this pull request Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Update of dependencies on hold There is a blocker, we need to wait
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants