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

DataCloneError when using snapshotFormat.plugins #4134

Closed
6 tasks done
ambarvm opened this issue Sep 17, 2023 · 2 comments · Fixed by #4204
Closed
6 tasks done

DataCloneError when using snapshotFormat.plugins #4134

ambarvm opened this issue Sep 17, 2023 · 2 comments · Fixed by #4204
Labels
documentation Improvements or additions to documentation pr welcome

Comments

@ambarvm
Copy link

ambarvm commented Sep 17, 2023

Describe the bug

Using snapshotFormat.plugins in vite.config.ts results in this error. The error is very different on stackblitz but I think this local error shows more relevant info.

DataCloneError: (val) => Array.isArray(val) could not be cloned.
 ❯ new DOMException node:internal/per_context/domexception:53:5
 ❯ WorkerInfo.postTask node_modules/.pnpm/tinypool@0.7.0/node_modules/tinypool/dist/esm/index.js:440:17
 ❯ ThreadPool.runTask node_modules/.pnpm/tinypool@0.7.0/node_modules/tinypool/dist/esm/index.js:732:16
 ❯ Tinypool.run node_modules/.pnpm/tinypool@0.7.0/node_modules/tinypool/dist/esm/index.js:808:38
 ❯ runFiles node_modules/.pnpm/vitest@0.34.4/node_modules/vitest/dist/vendor-node.b14cb9ad.js:7328:20
 ❯ node_modules/.pnpm/vitest@0.34.4/node_modules/vitest/dist/vendor-node.b14cb9ad.js:7370:98
 ❯ Object.runTests node_modules/.pnpm/vitest@0.34.4/node_modules/vitest/dist/vendor-node.b14cb9ad.js:7370:58
 ❯ Object.runTests node_modules/.pnpm/vitest@0.34.4/node_modules/vitest/dist/vendor-node.b14cb9ad.js:7661:5

If run withvitest --threads=false, a different error is shown

 FAIL  test/suite.test.ts > suite name > snapshot
PrettyFormatPluginError: plugins[p].test is not a function
 ❯ findPlugin file:/home/projects/vitest-dev-vitest-vr4kaa/node_modules/pretty-format/build/index.js:302:22
 ❯ format file:/home/projects/vitest-dev-vitest-vr4kaa/node_modules/pretty-format/build/index.js:451:32
 ❯ file:/home/projects/vitest-dev-vitest-vr4kaa/test/suite.test.ts:11:50

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-vr4kaa?file=vite.config.ts

System Info

System:
    OS: macOS 13.5.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 2.59 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
    pnpm: 8.6.1 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 16.6
  npmPackages:
    vitest: ^0.34.4 => 0.34.4

Used Package Manager

pnpm

Validations

@stackblitz
Copy link

stackblitz bot commented Sep 17, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sheremet-va
Copy link
Member

Plugins option is not supported there. Use expect.addSnapshotSerializer inside the setup file.

But Vitest should print the warning and remove all function options from the type.

@sheremet-va sheremet-va added documentation Improvements or additions to documentation pr welcome and removed pending triage labels Sep 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants