-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rerun tests, when setup file is edited (#2625)
Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com> fix #2614
- Loading branch information
1 parent
03af706
commit 019a6d5
Showing
8 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@vitest/test-setup", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"devDependencies": { | ||
"execa": "^6.1.0", | ||
"vitest": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ['tests/empty-setup.test.ts'], | ||
setupFiles: ['setupFiles/empty-setup.ts'], | ||
}, | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, it } from 'vitest' | ||
|
||
it('should success', async () => { | ||
expect(1 + 1).toBe(2) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { promises as fs } from 'fs' | ||
import { afterEach, describe, expect, it } from 'vitest' | ||
import { execa } from 'execa' | ||
|
||
const run = async () => await execa('vitest', ['run', '--changed', '--config', 'setup.vitest.config.ts']) | ||
|
||
describe('setup files with forceRerunTrigger', () => { | ||
const file = './setupFiles/empty-setup.ts' | ||
|
||
afterEach(async () => { | ||
await fs.writeFile(file, '', 'utf-8') | ||
}) | ||
|
||
it('should run no tests if setup file is not changed', async () => { | ||
const { stdout } = await run() | ||
expect(stdout).toContain('No test files found, exiting with code 0') | ||
}, 60_000) | ||
|
||
it('should run the whole test suite if setup file is changed', async () => { | ||
const codes = 'export const a = 1' | ||
await fs.writeFile(file, codes, 'utf-8') | ||
const { stdout } = await run() | ||
expect(stdout).toContain('1 passed') | ||
}, 60_000) | ||
}) |