[0.18.1] TypeError: Symbol.hasInstance is read-only
See original GitHub issueDescribe the bug
My tests that use vi.mock
(in this case, mocking out the ora
module) started failing as of vitest v0.18.1 with the following error:
TypeError: Cannot assign to read only property 'Symbol(Symbol.hasInstance)' of function 'function(...o) {
if (e.called = !0, e.callCount++, e.calls.push(o), e.next) {
let [s, l] = e.next;
...<omitted>... }'
In the reproduction (below), it presents itself as simply: TypeError: Symbol.hasInstance is read-only
I’m assuming this is related to PR #1648 but I’m not sure if I need to update my usage to comply with the intent of the PR or what.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-ht4a9x?file=test/mock.test.ts&view=editor
System Info
System:
OS: Windows 10 10.0.19044
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 17.74 GB / 31.92 GB
Binaries:
Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.12.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 103.0.5060.114
Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.62)
Internet Explorer: 11.0.19041.1566
npmPackages:
vitest: 0.18.1 => 0.18.1
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Symbol.hasInstance - JavaScript - MDN Web Docs
The Symbol.hasInstance well-known symbol is used to determine if a constructor object recognizes an object as its instance.
Read more >Why can I not assign Symbol.hasInstance onto a function?
The reason is because the property descriptor for Function.prototype[Symbol.hasInstance] has {writable: false} , which makes it not possible ...
Read more >Raw file - Public Repositories - IBS Bitbucket
moveStart('character', pos);\n range.select();\n }\n}\n\nvar ... _pluginName = toUpperCaseFirst(pluginName);\n\n if (!registeredPlugins.has(instance) || !
Read more >Untitled
undefined":r(i)))throw new TypeError(i+"must be non-object");for(var o in i)n(i ... W+a.F*!L,{Symbol:A});for(var te="hasInstance,isConcatSpreadable,iterator ...
Read more >Customizing ES6 via well-known symbols - 2ality
In ECMAScript 6, the object Symbol has several properties that contain ... obj.prop = 456; // TypeError: Cannot assign to read-only property.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please, don’t post comments like “still not working”. When someone will work on a fix, it will be displayed here.
Figured out a fix! #1786.