[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: forceRerunTriggers correctly triggers a rerun (#3829)

authored by

Vladimir and committed by
GitHub
(Jul 28, 2023, 11:13 AM +0200) 17988e51 280e6745

+22 -1
+4
test/watch/fixtures/vitest.config.ts
··· 10 10 11 11 // This configuration is edited by tests 12 12 reporters: 'verbose', 13 + 14 + forceRerunTriggers: [ 15 + '**/force-watch/**', 16 + ], 13 17 }, 14 18 })
+16
test/watch/test/file-watching.test.ts
··· 12 12 const configFile = 'fixtures/vitest.config.ts' 13 13 const configFileContent = readFileSync(configFile, 'utf-8') 14 14 15 + const forceTriggerFile = 'fixtures/force-watch/trigger.js' 16 + const forceTriggerFileContent = readFileSync(forceTriggerFile, 'utf-8') 17 + 15 18 const cliArgs = ['--root', 'fixtures', '--watch'] 16 19 const cleanups: (() => void)[] = [] 17 20 ··· 26 29 writeFileSync(sourceFile, sourceFileContent, 'utf8') 27 30 writeFileSync(testFile, testFileContent, 'utf8') 28 31 writeFileSync(configFile, configFileContent, 'utf8') 32 + writeFileSync(forceTriggerFile, forceTriggerFileContent, 'utf8') 29 33 cleanups.splice(0).forEach(cleanup => cleanup()) 30 34 }) 31 35 ··· 37 41 await vitest.waitForStdout('New code running') 38 42 await vitest.waitForStdout('RERUN ../math.ts') 39 43 await vitest.waitForStdout('1 passed') 44 + }) 45 + 46 + test('editing force rerun trigger reruns all tests', async () => { 47 + const vitest = await runVitestCli(...cliArgs) 48 + 49 + writeFileSync(forceTriggerFile, editFile(forceTriggerFileContent), 'utf8') 50 + 51 + await vitest.waitForStdout('Waiting for file changes...') 52 + await vitest.waitForStdout('RERUN ../force-watch/trigger.js') 53 + await vitest.waitForStdout('example.test.ts') 54 + await vitest.waitForStdout('math.test.ts') 55 + await vitest.waitForStdout('2 passed') 40 56 }) 41 57 42 58 test('editing test file triggers re-run', async () => {
+1 -1
packages/vitest/src/node/core.ts
··· 644 644 645 645 if (mm.isMatch(id, this.config.forceRerunTriggers)) { 646 646 this.state.getFilepaths().forEach(file => this.changedTests.add(file)) 647 - return [] 647 + return [id] 648 648 } 649 649 650 650 const projects = this.getModuleProjects(id)
+1
test/watch/fixtures/force-watch/trigger.js
··· 1 + export const trigger = false