GithubHelp home page GithubHelp logo

Comments (10)

robinelvin avatar robinelvin commented on June 15, 2024 2

Similar issue here. Running tests using vitest in a "node" environment works but running with "jsdom" stops with the following:

Error: The "path" argument must be of type string or an instance of URL. Received an instance of URL
 ❯ makeError ../../.pnp.cjs:36106:34
 ❯ applyNodeExportsResolution ../../.pnp.cjs:37438:13
 ❯ resolveUnqualifiedExport ../../.pnp.cjs:37824:35
 ❯ resolveRequest ../../.pnp.cjs:37909:106
 ❯ Object.resolveRequest ../../.pnp.cjs:37966:26
 ❯ resolve$1 ../../.pnp.loader.mjs:1997:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_INVALID_ARG_TYPE', pnpCode: 'EXPORTS_RESOLUTION_FAILED', data: { unqualifiedPath: '/Users/rob/Projects/Elixir/core-develop/.yarn/cache/@vitest-runner-npm-0.34.6-dae9162b5c-3525d8e4f8.zip/node_modules/@vitest/runner/utils', locator: { name: '@vitest/runner', reference: 'npm:0.34.6' }, pkgJson: { name: '@vitest/runner', type: 'module', version: '0.34.6', description: 'Vitest test runner', license: 'MIT', funding: 'https://opencollective.com/vitest', homepage: 'https://github.com/vitest-dev/vitest/tree/main/packages/runner#readme', repository: { type: 'git', url: 'git+https://github.com/vitest-dev/vitest.git', directory: 'packages/runner' }, bugs: { url: 'https://github.com/vitest-dev/vitest/issues' }, sideEffects: true, exports: { '.': { types: './dist/index.d.ts', import: './dist/index.js' }, './utils': { types: './dist/utils.d.ts', import: './dist/utils.js' }, './types': { types: './dist/types.d.ts', import: './dist/types.js' }, './*': './*' }, main: './dist/index.js', module: './dist/index.js', types: './dist/index.d.ts', files: [ 'dist', '*.d.ts' ], dependencies: { 'p-limit': '^4.0.0', pathe: '^1.1.1', '@vitest/utils': '0.34.6' }, scripts: { build: 'rimraf dist && rollup -c', dev: 'rollup -c --watch' } }, subpath: 'utils', conditions: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: 3, values: 'Function<values>', keys: 'Function<values>' }, request: '@vitest/runner/utils', issuer: '/Users/rob/Projects/Elixir/core-develop/.yarn/__virtual__/vitest-virtual-68e5eaf46b/0/cache/vitest-npm-0.34.6-48e1d6f80a-0191422ab9.zip/node_modules/vitest/dist/index.js' } }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

I think this is due to the dynamic import inside vitest here

from vitest.

wojtekmaj avatar wojtekmaj commented on June 15, 2024 1

Shoot! It looks like one indeed. I hope however that the research, workarounds, and reproducible repo will come in handy.

from vitest.

robinelvin avatar robinelvin commented on June 15, 2024 1

Contrary to what this ticket is about I have switched to happy-dom by defining the dependency in .yarnrc.yml and changing the test file comment header. My tests now work.

packageExtensions:
  local-pkg@*:
    peerDependencies:
      "happy-dom": "*"

from vitest.

randompixel avatar randompixel commented on June 15, 2024 1

I am getting the same error as #4413 (comment)

 FAIL  tests/unit/services/browserCheck.test.js [ tests/unit/services/browserCheck.test.js ]
Error: The "path" argument must be of type string or an instance of URL. Received an instance of URL
 ❯ makeError .pnp.cjs:25457:34
 ❯ applyNodeExportsResolution .pnp.cjs:26789:13
 ❯ resolveUnqualifiedExport .pnp.cjs:27175:35
 ❯ resolveRequest .pnp.cjs:27260:106
 ❯ Object.resolveRequest .pnp.cjs:27317:26
 ❯ resolve$1 .pnp.loader.mjs:2019:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_INVALID_ARG_TYPE', pnpCode: 'EXPORTS_RESOLUTION_FAILED', data: { unqualifiedPath:
....

However this appears to only affect 0.34.6. If I downgrade to vitest 0.34.5 then the tests work fine.

Using Yarn 4.0.2 with PNP. Vite 4.5.0

from vitest.

sheremet-va avatar sheremet-va commented on June 15, 2024

Looks like this is a duplicate of #899

from vitest.

sheremet-va avatar sheremet-va commented on June 15, 2024

This is because node‘s URL is overriden by jsdom URL

from vitest.

robinelvin avatar robinelvin commented on June 15, 2024

This is because node‘s URL is overriden by jsdom URL

Ok, so is there a fix or workaround?

from vitest.

sheremet-va avatar sheremet-va commented on June 15, 2024

You can override URL in setup files:

import { URL } from 'node:url'
globalThis.URL = URL

This might break some JSDOM API.

from vitest.

robinelvin avatar robinelvin commented on June 15, 2024

@sheremet-va Unfortunately this doesn't work. vitest crashes with the error before the setup files are executed. Additionally, it can't be added to the global setup or the vitest config.

I don't quite understand why this hack is required since it works perfectly well if using the normal node_modules mode.

from vitest.

sheremet-va avatar sheremet-va commented on June 15, 2024

I guess it uses global URL which is overriden by jsdom and incompatible with "path" module (url parser was updated in Node bot so long ago)

from vitest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.