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

Vitest shows provider as undefined for browsers even though provided in config #7303

Open
6 tasks done
NaviTheCoderboi opened this issue Jan 20, 2025 · 5 comments · May be fixed by #7313
Open
6 tasks done

Vitest shows provider as undefined for browsers even though provided in config #7303

NaviTheCoderboi opened this issue Jan 20, 2025 · 5 comments · May be fixed by #7313

Comments

@NaviTheCoderboi
Copy link

NaviTheCoderboi commented Jan 20, 2025

Describe the bug

When use vitest browser mode, it gives such error even i have provided correct config as mentioned in docs - https://main.vitest.dev/guide/browser/#configuration

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

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

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: Cannot read properties of undefined (reading 'provider')
  executeTests node_modules/.pnpm/@vitest+browser@3.0.2_@types+node@22.10.6_playwright@1.49.1_typescript@5.7.3_vite@6.0.7_@type_do4ccanmhzjdyssuzidjwadwgi/node_modules/@vitest/browser/dist/index.js:2997:30
  runWorkspaceTests node_modules/.pnpm/@vitest+browser@3.0.2_@types+node@22.10.6_playwright@1.49.1_typescript@5.7.3_vite@6.0.7_@type_do4ccanmhzjdyssuzidjwadwgi/node_modules/@vitest/browser/dist/index.js:3083:13
  executeTests node_modules/.pnpm/vitest@3.0.2_@types+node@22.10.6_@vitest+browser@3.0.2_happy-dom@16.5.3_msw@2.7.0_@types+node@22.10.6_typescript@5.7.3_/node_modules/vitest/dist/chunks/resolveConfig.DATSOo7x.js:7720:5
  node_modules/.pnpm/vitest@3.0.2_@types+node@22.10.6_@vitest+browser@3.0.2_happy-dom@16.5.3_msw@2.7.0_@types+node@22.10.6_typescript@5.7.3_/node_modules/vitest/dist/chunks/cli-api.B7hOUwun.js:12524:11

my config

import { svelte } from '@sveltejs/vite-plugin-svelte';
import { configDefaults, defineConfig } from 'vitest/config';

export default defineConfig({
    plugins: [svelte()],
    cacheDir: './.cache/vitest',
    test: {
        exclude: configDefaults.exclude,
        workspace: [
            {
                test: {
                    // include: ['packages/**/*.@(svelte.)test.ts'],
                    name: 'browser',
                    browser: {
                        provider: 'playwright',
                        enabled: true,
                        instances: [
                            {
                                browser: 'chromium'
                            }
                        ]
                    }
                }
            }
        ]
    }
});

Reproduction

https://github.com/NaviTheCoderboi/vitest-repro

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM) i5-6500T CPU @ 2.50GHz  
    Memory: 2.05 GB / 7.88 GB
  Binaries:
    Node: 23.2.0 - ~\scoop\apps\nodejs\current\node.EXE    
    npm: 10.9.0 - ~\scoop\apps\nodejs\current\npm.CMD      
    pnpm: 9.15.2 - ~\scoop\apps\nodejs\current\bin\pnpm.CMD
    bun: 1.1.34 - ~\scoop\shims\bun.EXE
  Browsers:
    Edge: Chromium (117.0.2045.31)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @vitest/browser: ^3.0.2 => 3.0.2 
    vitest: ^3.0.2 => 3.0.2

Used Package Manager

pnpm

Validations

@ranisalt
Copy link

I am having the same issue and it started with v3.0.0 (v3.0.1 also has the same problem). It is working as expected with v2.1.8, I suppose this issue was introduced with the changed configuration structure from name to instances

@jfairley
Copy link

I noticed that running my entire suite works. It's only when I call out my browser workspace that it fails.

This led to find that excluding the other workspaces works. 🤯

For me, that's --project !unit.

@NaviTheCoderboi
Copy link
Author

NaviTheCoderboi commented Jan 21, 2025

I noticed that running my entire suite works. It's only when I call out my browser workspace that it fails.

This led to find that excluding the other workspaces works. 🤯

For me, that's --project !unit.

I have only browser tests , so I can't exclude them , 😂

@hatai
Copy link

hatai commented Jan 22, 2025

I am having the same issue...

Error logs

❯ pnpm run test:component

> [email protected] test:component /Users/taigen.hamada/projects/icare/vue3/app/frontend
> vitest --project component

WARN No story files found for the specified pattern: pages/**/*.stories.ts

 DEV  v3.0.3 /Users/taigen.hamada/projects/icare/vue3/app/frontend

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

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

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: Cannot read properties of undefined (reading 'provider')
 ❯ getThreadsCount ../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_@ty_rsjsyalurh3tlejngvzgbhp4yi/node_modules/@vitest/browser/dist/index.js:3089:46
 ❯ executeTests ../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_@ty_rsjsyalurh3tlejngvzgbhp4yi/node_modules/@vitest/browser/dist/index.js:2996:26
 ❯ runWorkspaceTests ../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_@ty_rsjsyalurh3tlejngvzgbhp4yi/node_modules/@vitest/browser/dist/index.js:3083:13
 ❯ executeTests ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/resolveConfig.9CnFfuqj.js:7720:5
 ❯ ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/cli-api.BaY17YBo.js:12524:11
 ❯ Vitest.runFiles ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/cli-api.BaY17YBo.js:12551:12
 ❯ Vitest.start ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/cli-api.BaY17YBo.js:12431:21
 ❯ startVitest ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/cli-api.BaY17YBo.js:13563:7
 ❯ start ../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_jsdom@25._wa7qawb64or6limf5r55rud6za/node_modules/vitest/dist/chunks/cac.Cfe6a4o8.js:1571:17

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯


 Test Files   (1)
      Tests  no tests
     Errors  1 error
   Start at  18:27:57
   Duration  4.57s (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)


System Info

  System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M3
    Memory: 111.20 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.local/share/mise/installs/node/18.20.2/bin/node
    npm: 10.5.0 - ~/.local/share/mise/installs/node/18.20.2/bin/npm
    pnpm: 9.15.1 - ~/.local/share/mise/installs/node/18.20.2/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.265
    Edge: 132.0.2957.115
    Safari: 18.2
  npmPackages:
    @vitejs/plugin-legacy: ^6.0.0 => 6.0.0 
    @vitejs/plugin-vue: ^5.2.1 => 5.2.1 
    @vitest/browser: ^3.0.3 => 3.0.3 
    vite: ^6.0.11 => 6.0.11 
    vitest: ^3.0.3 => 3.0.3 

@sheremet-va sheremet-va linked a pull request Jan 22, 2025 that will close this issue
6 tasks
@sheremet-va
Copy link
Member

This is the same issue as #7308

Please wait for a fix in #7313

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

Successfully merging a pull request may close this issue.

5 participants