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: (path) => path.replace(/^\/oc/, '') could not be cloned #587

Closed
Ibochkarev opened this issue Apr 19, 2023 · 6 comments
Closed

Comments

@Ibochkarev
Copy link

Ibochkarev commented Apr 19, 2023

After updating to 0.6.10 on Nuht 3 version 3.4.1, i get an error when I try to start

"vitest-environment-nuxt": "^0.6.10"

❯ yarn test-ui
(node:51339) V8: /Users/ibochkarev/Projects/XXXX/XXXX/node_modules/ttf2woff2/jssrc/ttf2woff2.js:3 Invalid asm.js: Invalid member of stdlib
(Use `node --trace-warnings ...` to show where the warning was created)

 DEV  v0.30.1 /Users/ibochkarev/Projects/XXXX/XXXX
      UI started at http://localhost:51204/__vitest__/


 Test Files  no tests
      Tests  no tests
   Start at  13:52:13
   Duration  368ms (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 39 unhandled errors during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
DataCloneError: (path) => path.replace(/^\/oc/, '') could not be cloned.
 ❯ new DOMException node:internal/per_context/domexception:72:5
 ❯ WorkerInfo.postTask node_modules/tinypool/dist/esm/index.js:421:17
 ❯ ThreadPool.runTask node_modules/tinypool/dist/esm/index.js:712:16
 ❯ Tinypool.run node_modules/tinypool/dist/esm/index.js:760:38
 ❯ runFiles node_modules/vitest/dist/vendor-cli-api.70680cd5.js:7217:20
 ❯ node_modules/vitest/dist/vendor-cli-api.70680cd5.js:7254:99
 ❯ Object.runTests node_modules/vitest/dist/vendor-cli-api.70680cd5.js:7254:59
 ❯ Object.runTests node_modules/vitest/dist/vendor-cli-api.70680cd5.js:7396:5
 ❯ async file:/Users/ibochkarev/Projects/umatech/premier.one-v3/node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13913:9
 ❯ Vitest.runFiles node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13927:12
 ❯ Vitest.start node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13836:5
 ❯ startVitest node_modules/vitest/dist/vendor-cli-api.70680cd5.js:20784:5

This line, which swears at startup, is in nuxt.config.ts config in the proxy section and looks like this

'/oc': {
        target: process.env.NUXT_OC_BACKEND_API_URL,
        cookieDomainRewrite: '',
        changeOrigin: true,
        rewrite: (path: string) => path.replace('/^\/oc/, '')
      },

I tried excluding the config file:

import { configDefaults } from 'vitest/config'
import { defineVitestConfig } from 'nuxt-vitest/config'

export default defineVitestConfig({
  // any custom vitest config you require
  test: {
    environment: 'nuxt',
    exclude: [...configDefaults.exclude, ['src/shared/api/**', 'public/**', 'node_modules/**', 'nuxt.config.ts']],
  },
})

but now I get the error

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: pattern.startsWith is not a function
 ❯ isNegativePattern node_modules/vitest/dist/vendor-cli-api.70680cd5.js:4702:20
 ❯ convertToPositivePattern node_modules/vitest/dist/vendor-cli-api.70680cd5.js:4694:12
 ❯ getNegativePatternsAsPositive node_modules/vitest/dist/vendor-cli-api.70680cd5.js:5044:31
 ❯ Object.generate node_modules/vitest/dist/vendor-cli-api.70680cd5.js:5004:30
 ❯ getWorks node_modules/vitest/dist/vendor-cli-api.70680cd5.js:6957:31
 ❯ FastGlob node_modules/vitest/dist/vendor-cli-api.70680cd5.js:6911:19
 ❯ WorkspaceProject.globFiles node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13473:12
 ❯ WorkspaceProject.globAllTestFiles node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13451:34
 ❯ WorkspaceProject.globTestFiles node_modules/vitest/dist/vendor-cli-api.70680cd5.js:13446:34
@Ibochkarev
Copy link
Author

Ibochkarev commented May 16, 2023

@danielroe Good afternoon, please tell me how to correctly exclude the nuxt.config.ts file from the test – an error appears at startup

image

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
DataCloneError: (path) => path.replace(/^\/oc/, '') could not be cloned.
import { defineVitestConfig } from 'nuxt-vitest/config'
import { configDefaults } from 'vitest/config'

export default defineVitestConfig({
  test: {
    globals: true,
    environment: 'nuxt',
    exclude: [
      ...configDefaults.exclude,
      'src/shared/api/**',
      'public/**',
      '**/node_modules/**',
      '**.config.ts',
      '**/__snapshots__/**',
      '.nuxt/**',
    ],
    coverage: {
      provider: 'c8',
      reportsDirectory: 'coverage',
      reporter: ['text', 'json', 'html'],
      exclude: [
        'src/shared/api/**',
        'public/**',
        '**/node_modules/**',
        '**.config.ts',
        '**/__snapshots__/**',
        '.nuxt/**',
      ],
      include: ['src/**'],
    },
    reporters: ['verbose', 'json'],
    outputFile: {
      json: 'coverage/test-report.json',
    },
  },
})

@hi-reeve
Copy link

have you found the fix?

@Ibochkarev
Copy link
Author

Ibochkarev commented Aug 22, 2023

have you found the fix?

@hi-reeve No

@danielroe
Copy link
Member

Can you provide a reproduction? 🙏

@hi-reeve
Copy link

Can you provide a reproduction? 🙏

weirdly i cannot reproduce this on stackblitz

@danielroe danielroe transferred this issue from danielroe/nuxt-vitest Dec 2, 2023
Copy link
Contributor

github-actions bot commented Dec 2, 2023

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-vitest
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-jest
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/module

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants