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

Tries to assign to a getter-only field when formatting an error #5406

Closed
6 tasks done
hikiko4ern opened this issue Mar 19, 2024 · 0 comments · Fixed by #5466
Closed
6 tasks done

Tries to assign to a getter-only field when formatting an error #5406

hikiko4ern opened this issue Mar 19, 2024 · 0 comments · Fixed by #5466
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@hikiko4ern
Copy link

Describe the bug

Comparing objects containing getters returning objects throws an error

TypeError: Cannot set property getter of #<Object> which has only a getter
    at file://<project>/node_modules/@vitest/utils/dist/error.js:138:19
    at Array.forEach (<anonymous>)
    at replaceAsymmetricMatcher (file://<project>/node_modules/@vitest/utils/dist/error.js:122:30)
    at processError (file://<project>/node_modules/@vitest/utils/dist/error.js:85:50)
    at failTask (file://<project>/node_modules/@vitest/runner/dist/index.js:843:19)
    at runTest (file://<project>/node_modules/@vitest/runner/dist/index.js:783:9)
    at runSuite (file://<project>/node_modules/@vitest/runner/dist/index.js:895:15)
    at runFiles (file://<project>/node_modules/@vitest/runner/dist/index.js:944:5)
    at startTests (file://<project>/node_modules/@vitest/runner/dist/index.js:953:3)
    at file://<project>/node_modules/vitest/dist/chunks/runtime-runBaseTests.SKlFOhuq.js:114:7

because replaceAsymmetricMatcher is trying to assign a value to the getter property here

actual[key] = replaced.replacedActual

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-9gejrs?file=test%2Findex.test.ts

System Info

System:
  OS: Linux 5.15 Debian GNU/Linux trixie/sid
  CPU: (32) x64 AMD Ryzen 9 7950X3D 16-Core Processor
  Memory: 52.62 GB / 64.76 GB
  Container: Yes
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.11.0 - /mnt/wslg/runtime-dir/fnm_multishells/18318_1710853269088/bin/node
  Yarn: 4.1.1 - /mnt/wslg/runtime-dir/fnm_multishells/18318_1710853269088/bin/yarn
  npm: 10.4.0 - /mnt/wslg/runtime-dir/fnm_multishells/18318_1710853269088/bin/npm
  bun: 1.0.33 - ~/.bun/bin/bun
Browsers:
  Chrome: 120.0.6099.216
  Chromium: 120.0.6099.199
npmPackages:
  @vitest/ui: latest => 1.4.0
  vite: latest => 5.1.6
  vitest: latest => 1.4.0

Used Package Manager

yarn

Validations

@hi-ogawa hi-ogawa added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Mar 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants