()
| 165 | name: 'vitest:browser:tests', |
| 166 | enforce: 'pre', |
| 167 | async config() { |
| 168 | // this plugin can be used in different projects, but all of them |
| 169 | // have the same `include` pattern, so it doesn't matter which project we use |
| 170 | const project = parentServer.project |
| 171 | const { testFiles: browserTestFiles } = await project.globTestFiles() |
| 172 | const setupFiles = toArray(project.config.setupFiles) |
| 173 | |
| 174 | // replace env values - cannot be reassign at runtime |
| 175 | const define: Record<string, string> = {} |
| 176 | for (const env in (project.config.env || {})) { |
| 177 | const stringValue = JSON.stringify(project.config.env[env]) |
| 178 | define[`import.meta.env.${env}`] = stringValue |
| 179 | } |
| 180 | |
| 181 | const entries: string[] = [ |
| 182 | ...browserTestFiles, |
| 183 | ...setupFiles, |
| 184 | resolve(vitestDist, 'index.js'), |
| 185 | resolve(vitestDist, 'browser.js'), |
| 186 | resolve(vitestDist, 'runners.js'), |
| 187 | resolve(vitestDist, 'utils.js'), |
| 188 | ...(project.config.snapshotSerializers || []), |
| 189 | ] |
| 190 | |
| 191 | const exclude = [ |
| 192 | 'vitest', |
| 193 | 'vitest/browser', |
| 194 | 'vitest/internal/browser', |
| 195 | 'vite/module-runner', |
| 196 | '@vitest/browser/utils', |
| 197 | '@vitest/browser/context', |
| 198 | '@vitest/browser/client', |
| 199 | '@vitest/utils', |
| 200 | '@vitest/utils/source-map', |
| 201 | '@vitest/runner', |
| 202 | '@vitest/spy', |
| 203 | '@vitest/utils/error', |
| 204 | '@vitest/snapshot', |
| 205 | '@vitest/expect', |
| 206 | 'std-env', |
| 207 | 'tinybench', |
| 208 | 'tinyspy', |
| 209 | 'tinyrainbow', |
| 210 | 'pathe', |
| 211 | 'msw', |
| 212 | 'msw/browser', |
| 213 | ] |
| 214 | |
| 215 | if (typeof project.config.diff === 'string') { |
| 216 | entries.push(project.config.diff) |
| 217 | } |
| 218 | |
| 219 | if (parentServer.vitest.coverageProvider) { |
| 220 | const coverage = parentServer.vitest._coverageOptions |
| 221 | const provider = coverage.provider |
| 222 | if (provider === 'v8') { |
| 223 | const path = tryResolve('@vitest/coverage-v8', [parentServer.config.root]) |
| 224 | if (path) { |
nothing calls this directly
no test coverage detected