fix(coverage): exclude to not inherit negation globs from `test.inc… · vitest-dev/vitest@286851e (original) (raw)

`@@ -59,6 +59,19 @@ test('include without actual glob', async () => {

`

59

59

`expect.soft(isIncluded('src-file-in-root.js')).toBe(false)

`

60

60

`})

`

61

61

``

``

62

`+

test('test.include with negations', async () => {

`

``

63

`+

const isIncluded = await init({

`

``

64

`+

include: ['src/**'],

`

``

65

`+

testInclude: ['!something'],

`

``

66

`+

})

`

``

67

+

``

68

`+

expect.soft(isIncluded('src/component.js')).toBe(true)

`

``

69

`+

expect.soft(isIncluded('src/nested/component.ts')).toBe(true)

`

``

70

+

``

71

`+

expect.soft(isIncluded('top-level.ts')).toBe(false)

`

``

72

`+

expect.soft(isIncluded('utils/math.ts')).toBe(false)

`

``

73

`+

})

`

``

74

+

62

75

`test('no include defaults to match all files', async () => {

`

63

76

`const isIncluded = await init({

`

64

77

`exclude: [],

`

`@@ -131,10 +144,10 @@ test('files outside project when allowExternal: true', async () => {

`

131

144

`expect(isIncluded(resolve(process.cwd(), '../../package-b/src/two.ts'))).toBe(false)

`

132

145

`})

`

133

146

``

134

``

`-

async function init(options: Partial) {

`

``

147

`+

async function init(options: Partial & { testInclude?: string[] }) {

`

135

148

`const vitest = await createVitest('test', {

`

136

149

`config: false,

`

137

``

`-

include: ['dont-match-anything'],

`

``

150

`+

include: ['dont-match-anything', ...(options.testInclude || [])],

`

138

151

`coverage: {

`

139

152

` ...options,

`

140

153

`enabled: true,

`

`@@ -143,7 +156,7 @@ async function init(options: Partial) {

`

143

156

`}, {}, { stdout: new Writable() })

`

144

157

``

145

158

`onTestFinished(() => vitest.close())

`

146

``

`-

await vitest.init()

`

``

159

`+

await vitest.standalone()

`

147

160

``

148

161

`const provider = vitest.coverageProvider as unknown as BaseCoverageProvider

`

149

162

``