Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c3be6f

Browse filesBrowse files
authored
fix(coverage): ignore SCSS in browser mode (#8161)
1 parent bd2c481 commit 0c3be6f
Copy full SHA for 0c3be6f

File tree

Expand file treeCollapse file tree

7 files changed

+318
-68
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+318
-68
lines changed
Open diff view settings
Collapse file

‎packages/browser/src/node/providers/playwright.ts‎

Copy file name to clipboardExpand all lines: packages/browser/src/node/providers/playwright.ts
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
} from 'vitest/node'
2121
import { createManualModuleSource } from '@vitest/mocker/node'
2222
import c from 'tinyrainbow'
23-
import { createDebugger } from 'vitest/node'
23+
import { createDebugger, isCSSRequest } from 'vitest/node'
2424

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

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

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

478476
function isDirectCSSRequest(request: string): boolean {
479-
return CSS_LANGS_RE.test(request) && directRequestRE.test(request)
477+
return isCSSRequest(request) && directRequestRE.test(request)
480478
}
Collapse file

‎packages/coverage-istanbul/src/provider.ts‎

Copy file name to clipboardExpand all lines: packages/coverage-istanbul/src/provider.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { resolve } from 'pathe'
1616
import TestExclude from 'test-exclude'
1717
import c from 'tinyrainbow'
1818
import { BaseCoverageProvider } from 'vitest/coverage'
19+
import { isCSSRequest } from 'vitest/node'
1920

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

Collapse file

‎packages/vitest/src/public/node.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/public/node.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export type { SerializedError } from '@vitest/utils'
168168

169169
export {
170170
esbuildVersion,
171+
isCSSRequest,
171172
isFileServingAllowed,
172173
parseAst,
173174
parseAstAsync,
Collapse file

‎pnpm-lock.yaml‎

Copy file name to clipboardExpand all lines: pnpm-lock.yaml
+302-63Lines changed: 302 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎test/core/test/exports.test.ts‎

Copy file name to clipboardExpand all lines: test/core/test/exports.test.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ it('exports snapshot', async ({ skip, task }) => {
103103
"esbuildVersion": "string",
104104
"generateFileHash": "function",
105105
"getFilePoolName": "function",
106+
"isCSSRequest": "function",
106107
"isFileServingAllowed": "function",
107108
"isValidApiRequest": "function",
108109
"parseAst": "function",
@@ -259,6 +260,7 @@ it('exports snapshot', async ({ skip, task }) => {
259260
"esbuildVersion": "string",
260261
"generateFileHash": "function",
261262
"getFilePoolName": "function",
263+
"isCSSRequest": "function",
262264
"isFileServingAllowed": "function",
263265
"isValidApiRequest": "function",
264266
"parseAst": "function",
Collapse file

‎test/coverage-test/fixtures/src/Vue/Hello.vue‎

Copy file name to clipboardExpand all lines: test/coverage-test/fixtures/src/Vue/Hello.vue
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ defineExpose(props)
1515
x1
1616
</button>
1717
</template>
18+
19+
<!-- Style block triggers a specific condition where sourcemaps used to break randomly -->
20+
<!-- https://github.com/vitest-dev/vitest/issues/8154 -->
21+
<style lang="scss">
22+
body {
23+
background-color: #FFF;
24+
}
25+
</style>
Collapse file

‎test/coverage-test/package.json‎

Copy file name to clipboardExpand all lines: test/coverage-test/package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"istanbul-lib-report": "catalog:",
2222
"magic-string": "^0.30.17",
2323
"magicast": "^0.3.5",
24+
"sass-embedded": "^1.89.2",
2425
"unplugin-swc": "^1.5.4",
2526
"vite": "latest",
2627
"vitest": "workspace:*",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.