Skip to content

RangeError: path should be a path.relative()d string, #714

@xavier-ottolini

Description

@xavier-ottolini

Describe the bug

A can not run test with the Vitest extension. I tried with Antigravity and with VS Code. I get the same result.

Reproduction

I have got a typescript projet with

  • Nuxt 3.17 project
  • vitest 3.0.24
  • vitest/ui 3.0.24
  • @nuxt/test-utils 3.0.17

Here is the vitest.config.ts:

import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
  test: {
    environment: 'nuxt',
    globals: true,
    include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
    exclude: ['**/node_modules/**', '**/dist/**', '.nuxt/**', '**/.{git,cache,output,temp}/**'],
    // you can optionally set Nuxt-specific environment options
    environmentOptions: {
      nuxt: {
        mock: {
          intersectionObserver: true,
          indexedDb: true,
        },
        rootDir: fileURLToPath(new URL('./', import.meta.url)),
      },
    },
  },
})

When I run the tests with the command npm run test, the tests are successful.

If I use the Testing view of IDE such as Antigravity or VS Code, I click on the play button of the *.test.ts file, there is an error:

Image

Before I was using another extension: "zixuanchen.vitest-explorer". There was not any errors but this extension is deprecated.

Output

Here is the Vitest output 

INFO 8:52:24 AM] [Worker] Found location for test should handle arrays containing objects 57:29 -> 101:
[INFO 8:52:24 AM] [Worker] Found location for test should handle objects containing arrays 64:29 -> 111:
[INFO 8:52:26 AM] Running 1 file(s) with name pattern: ^\s?deepObjectEquals
[8:52:26 AM] Starting a test run because frontend/utils/ObjectUtils.test.ts triggered a watch rerun event
[8:52:26 AM] Enqueuing "should return true when both obj1 and obj2 are undefined"
[8:52:26 AM] Enqueuing "should return false when one is undefined and other is null"
[8:52:26 AM] Enqueuing "should return false when one is undefined and other is defined value"
[8:52:26 AM] Enqueuing "should return true when both obj1 and obj2 are null"
[8:52:26 AM] Enqueuing "should return false when obj1 is null and obj2 is not"
[8:52:26 AM] Enqueuing "should return false when obj2 is null and obj1 is not"
[8:52:26 AM] Enqueuing "should handle strings correctly"
[8:52:26 AM] Enqueuing "should handle booleans correctly"
[8:52:26 AM] Enqueuing "should handle numbers correctly"
[8:52:26 AM] Enqueuing "should handle arrays correctly"
[8:52:26 AM] Enqueuing "should handle objects correctly"
[8:52:26 AM] Enqueuing "should handle nested objects"
[8:52:26 AM] Enqueuing "should handle arrays containing objects"
[8:52:26 AM] Enqueuing "should handle objects containing arrays"
[Error 8:52:40 AM] Error in D:/workspace/ai-apps/frontend/utils/ObjectUtils.test.ts RangeError: path should be a `path.relative()`d string, but got "C:/Users/xavie/.vscode/extensions/vitest.explorer-1.38.0/dist/setupFile.mjs"
    at throwError (D:\workspace\ai-apps\frontend\node_modules\ignore\index.js:557:9)
    at checkPath (D:\workspace\ai-apps\frontend\node_modules\ignore\index.js:576:12)
    at Ignore._test (D:\workspace\ai-apps\frontend\node_modules\ignore\index.js:637:5)
    at Ignore.ignores (D:\workspace\ai-apps\frontend\node_modules\ignore\index.js:720:17)
    at isIgnored (file:///D:/workspace/ai-apps/frontend/node_modules/@nuxt/kit/dist/index.mjs:2293:42)
    at Object.transformInclude (file:///D:/workspace/ai-apps/frontend/node_modules/nuxt/dist/shared/nuxt.DAkeCY9U.mjs:2779:115)
    at TransformPluginContext.<anonymous> (file:///D:/workspace/ai-apps/frontend/node_modules/nuxt/node_modules/unplugin/dist/index.js:1509:43)
    at EnvironmentPluginContainer.transform (file:///D:/workspace/ai-apps/frontend/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42295:19)
    at async loadAndTransform (file:///D:/workspace/ai-apps/frontend/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:35735:27)
[INFO 8:52:40 AM] [DECOR] Reset all decorations.
[8:52:40 AM] Marking "ObjectUtils.test.ts" as failed with 1 errors

Extension Version

1.38.1

Vitest Version

3.0.24

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions