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

Cannot use --project in cliArguments if the project name contains spaces #7515

Closed
4 tasks done
cyyynthia opened this issue Feb 18, 2025 · 2 comments · Fixed by #7533
Closed
4 tasks done

Cannot use --project in cliArguments if the project name contains spaces #7515

cyyynthia opened this issue Feb 18, 2025 · 2 comments · Fixed by #7533
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@cyyynthia
Copy link

cyyynthia commented Feb 18, 2025

Describe the bug

Trying to do --project=\"browser (chromium)\" does not work and makes the extension fail to collect tests.

Reproduction

  • Configure Vitest with a workspace, one of the projects being browser mode using Playwright (see attached config fragments)
  • Set "vitest.cliArguments": "--project=\"browser (chromium)\"" in VSCode config
  • Try to refresh tests
export default {
  coverage: {
    provider: 'v8',
    reporter: ['cobertura', 'text'],
    reportsDirectory: './.reports/vitest/coverage',
    exclude: [...coverageConfigDefaults.exclude, '**/*.story.vue'],
  },
  workspace: [
    {
      extends: true,
      test: {
        name: 'unit',
        include: [
          'src/**/*.{test,spec}.?(c|m)[jt]s?(x)',
          'src/**/*.unit.{test,spec}.?(c|m)[jt]s?(x)',
        ],
        exclude: [...defaultExclude, 'src/**/*.browser.{test,spec}.?(c|m)[jt]s?(x)'],
      },
    },
    {
      extends: true,
      optimizeDeps: {
        include: ['vue', 'radix-vue', 'radix-vue/date'],
      },
      test: {
        name: 'browser',
        include: ['src/**/*.browser.{test,spec}.?(c|m)[jt]s?(x)'],
        browser: {
          enabled: true,
          provider: 'playwright',
          testerHtmlPath: './browser-test.html',
          instances: [
            { browser: 'chromium', context: { locale: 'en-US' } },
            { browser: 'firefox', context: { locale: 'en-US' } },
            { browser: 'webkit', context: { locale: 'en-US' } },
          ],

          screenshotFailures: true,
          screenshotDirectory: '.reports/vitest/screenshots',
        },
      },
    },
  ],
}

Output

[Error Error] Vitest failed to start: 
Error: No projects matched the filter "\"browser".
    at Vitest._setServer (file:///home/cynthia/files/projects/flopedt/flopedt/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]._b6de855f3acea15d69062a98c834205f/node_modules/vitest/dist/chunks/cli-api.az_rB_xZ.js:12318:13)
    at async handler (file:///home/cynthia/files/projects/flopedt/flopedt/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]._b6de855f3acea15d69062a98c834205f/node_modules/vitest/dist/chunks/cli-api.az_rB_xZ.js:13267:11)
    at async _createServer (file:///home/cynthia/files/projects/flopedt/flopedt/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:44149:20)
    at async createViteServer (file:///home/cynthia/files/projects/flopedt/flopedt/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]._b6de855f3acea15d69062a98c834205f/node_modules/vitest/dist/chunks/cli-api.az_rB_xZ.js:10059:18)
    at async Module.createVitest (file:///home/cynthia/files/projects/flopedt/flopedt/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]._b6de855f3acea15d69062a98c834205f/node_modules/vitest/dist/chunks/cli-api.az_rB_xZ.js:13307:18)
    at async Po (/home/cynthia/.vscode/extensions/vitest.explorer-1.14.1/dist/worker.js:21:8610)
    at async e (/home/cynthia/.vscode/extensions/vitest.explorer-1.14.1/dist/worker.js:21:10388)

Workaround

I have been able to work around this by doing --project=*chromium)

Extension Version

1.14.1

Vitest Version

3.0.5

Validations

@sheremet-va
Copy link
Member

This is an error with Vitest's parseCLI method, I will move this issue to the Vitest repo

@sheremet-va sheremet-va transferred this issue from vitest-dev/vscode Feb 18, 2025
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Feb 18, 2025
@sheremet-va sheremet-va moved this to P2 - 2 in Team Board Feb 18, 2025
@sheremet-va sheremet-va moved this from P2 - 2 to Approved in Team Board Feb 18, 2025
@sheremet-va
Copy link
Member

Should probably use something like https://www.npmjs.com/package/string-argv instead of splitting by .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants