Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/browser/src/node/providers/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
} from 'vitest/node'
import { createManualModuleSource } from '@vitest/mocker/node'
import c from 'tinyrainbow'
import { createDebugger } from 'vitest/node'
import { createDebugger, isCSSRequest } from 'vitest/node'

const debug = createDebugger('vitest:browser:playwright')

Expand Down Expand Up @@ -471,10 +471,8 @@ function genSourceMapUrl(map: SourceMap | string): string {
return `data:application/json;base64,${Buffer.from(map).toString('base64')}`
}

const CSS_LANGS_RE
= /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
const directRequestRE = /[?&]direct\b/

function isDirectCSSRequest(request: string): boolean {
return CSS_LANGS_RE.test(request) && directRequestRE.test(request)
return isCSSRequest(request) && directRequestRE.test(request)
}
3 changes: 2 additions & 1 deletion packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { resolve } from 'pathe'
import TestExclude from 'test-exclude'
import c from 'tinyrainbow'
import { BaseCoverageProvider } from 'vitest/coverage'
import { isCSSRequest } from 'vitest/node'

import { version } from '../package.json' with { type: 'json' }
import { COVERAGE_STORE_KEY } from './constants'
Expand Down Expand Up @@ -64,7 +65,7 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider<ResolvedCover
// Istanbul/babel cannot instrument CSS - e.g. Vue imports end up here.
// File extension itself is .vue, but it contains CSS.
// e.g. "Example.vue?vue&type=style&index=0&scoped=f7f04e08&lang.css"
if (id.endsWith('.css')) {
if (isCSSRequest(id)) {
return
}

Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/public/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export type { SerializedError } from '@vitest/utils'

export {
esbuildVersion,
isCSSRequest,
isFileServingAllowed,
parseAst,
parseAstAsync,
Expand Down
365 changes: 302 additions & 63 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions test/core/test/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ it('exports snapshot', async ({ skip, task }) => {
"esbuildVersion": "string",
"generateFileHash": "function",
"getFilePoolName": "function",
"isCSSRequest": "function",
"isFileServingAllowed": "function",
"isValidApiRequest": "function",
"parseAst": "function",
Expand Down Expand Up @@ -259,6 +260,7 @@ it('exports snapshot', async ({ skip, task }) => {
"esbuildVersion": "string",
"generateFileHash": "function",
"getFilePoolName": "function",
"isCSSRequest": "function",
"isFileServingAllowed": "function",
"isValidApiRequest": "function",
"parseAst": "function",
Expand Down
8 changes: 8 additions & 0 deletions test/coverage-test/fixtures/src/Vue/Hello.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ defineExpose(props)
x1
</button>
</template>

<!-- Style block triggers a specific condition where sourcemaps used to break randomly -->
<!-- https://github.com/vitest-dev/vitest/issues/8154 -->
<style lang="scss">
body {
background-color: #FFF;
}
</style>
1 change: 1 addition & 0 deletions test/coverage-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"istanbul-lib-report": "catalog:",
"magic-string": "^0.30.17",
"magicast": "^0.3.5",
"sass-embedded": "^1.89.2",
"unplugin-swc": "^1.5.4",
"vite": "latest",
"vitest": "workspace:*",
Expand Down