[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: remove setup files from coverage (#2574)

Closes https://github.com/vitest-dev/vitest/issues/2190

authored by

Gurkiran Singh and committed by
GitHub
(Jan 19, 2023, 10:57 AM +0100) 488e4b9f 3d8ef766

+24 -1
+2
test/coverage-test/setup.ts
··· 1 + // eslint-disable-next-line no-console 2 + console.log('Test Setup File')
+5
test/coverage-test/vitest.config.ts
··· 1 + import { resolve } from 'pathe' 1 2 import { defineConfig } from 'vitest/config' 2 3 import vue from '@vitejs/plugin-vue' 3 4 ··· 16 17 all: true, 17 18 reporter: ['html', 'text', 'lcov', 'json'], 18 19 }, 20 + setupFiles: [ 21 + resolve(__dirname, './setup.ts'), 22 + './src/another-setup.ts', 23 + ], 19 24 }, 20 25 })
+13
test/coverage-test/coverage-report-tests/generic.report.test.ts
··· 50 50 51 51 expect(files).toContain('importEnv.ts.html') 52 52 }) 53 + 54 + test('files should not contain a setup file', () => { 55 + const coveragePath = resolve('./coverage') 56 + const files = fs.readdirSync(coveragePath) 57 + 58 + expect(files).not.toContain('coverage-test') 59 + expect(files).not.toContain('setup.ts.html') 60 + 61 + const coverageSrcPath = resolve('./coverage/src') 62 + const srcFiles = fs.readdirSync(coverageSrcPath) 63 + 64 + expect(srcFiles).not.toContain('another-setup.ts.html') 65 + })
+2
test/coverage-test/src/another-setup.ts
··· 1 + // eslint-disable-next-line no-console 2 + console.log('Another Setup File')
+2 -1
packages/vitest/src/node/config.ts
··· 1 1 import { resolveModule } from 'local-pkg' 2 - import { normalize, resolve } from 'pathe' 2 + import { normalize, relative, resolve } from 'pathe' 3 3 import c from 'picocolors' 4 4 import type { ResolvedConfig as ResolvedViteConfig } from 'vite' 5 5 ··· 190 190 ?? resolve(resolved.root, file), 191 191 ), 192 192 ) 193 + resolved.coverage.exclude.push(...resolved.setupFiles.map(file => relative(resolved.root, file))) 193 194 194 195 resolved.forceRerunTriggers = [ 195 196 ...resolved.forceRerunTriggers,