You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting from Sinon version 11.1.0, it is no longer possible to stub properties and methods on window, as suggested in the readme:
let stub = sinon.stub(window, 'confirm');
stub.returns(true);
This will throw an error:
TypeError: Cannot read properties of undefined (reading 'get')
at getAccessor (webpack://__ember_auto_import__/./node_modules/sinon/lib/sinon/util/core/wrap-method.js?:1:1061)
at extendObjectWithWrappedMethods (webpack://__ember_auto_import__/./node_modules/sinon/lib/sinon/util/core/wrap-method.js?:8:208)
at wrapMethod (webpack://__ember_auto_import__/./node_modules/sinon/lib/sinon/util/core/wrap-method.js?:8:87)
at Function.stub (webpack://__ember_auto_import__/./node_modules/sinon/lib/sinon/stub.js?:3:1569)
at Sandbox.stub (webpack://__ember_auto_import__/./node_modules/sinon/lib/sinon/sandbox.js?:8:720)
at Object.<anonymous> (http://localhost:13123/assets/tests.js:41707:22)
I tracked it down to this PR in Sinon itself sinonjs/sinon#2378, which shipped in version 11.1.0. More specifically, it seems that Sinon may have a bug when trying to mock/stub properties on Proxy objects.
I understand that this may be for Sinon to fix, but it would be worth updating the readme to account for this. Maybe include a built-in option to easily mock and restore window methods/properties?
The text was updated successfully, but these errors were encountered:
The proxy did not support all handlers like `getOwnPropertyDescriptor` and `defineProperty`, which did not play nicely with the latest sinon versions. Fixes#478
Starting from Sinon version
11.1.0
, it is no longer possible to stub properties and methods onwindow
, as suggested in the readme:This will throw an error:
I tracked it down to this PR in Sinon itself sinonjs/sinon#2378, which shipped in version 11.1.0. More specifically, it seems that Sinon may have a bug when trying to mock/stub properties on Proxy objects.
This may be related to issues like #99
I understand that this may be for Sinon to fix, but it would be worth updating the readme to account for this. Maybe include a built-in option to easily mock and restore window methods/properties?
The text was updated successfully, but these errors were encountered: