-
-
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: stop the runner before restarting, restart on workspace config c…
…hange (#6859)
- Loading branch information
1 parent
6e793c6
commit b01df47
Showing
8 changed files
with
180 additions
and
19 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
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
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,93 @@ | ||
import { expect, test } from 'vitest' | ||
import { runInlineTests } from '../../test-utils' | ||
|
||
const ts = String.raw | ||
|
||
test('reruns tests when configs change', async () => { | ||
const { fs, vitest } = await runInlineTests({ | ||
'vitest.workspace.ts': [ | ||
'./project-1', | ||
'./project-2', | ||
], | ||
'vitest.config.ts': {}, | ||
'project-1/vitest.config.ts': {}, | ||
'project-1/basic.test.ts': ts` | ||
import { test } from 'vitest' | ||
test('basic test 1', () => {}) | ||
`, | ||
'project-2/vitest.config.ts': {}, | ||
'project-2/basic.test.ts': ts` | ||
import { test } from 'vitest' | ||
test('basic test 2', () => {}) | ||
`, | ||
}, { watch: true }) | ||
|
||
await vitest.waitForStdout('Waiting for file changes') | ||
vitest.resetOutput() | ||
|
||
// editing the project config should trigger a restart | ||
fs.editFile('./project-1/vitest.config.ts', c => `\n${c}`) | ||
|
||
await vitest.waitForStdout('Restarting due to config changes...') | ||
await vitest.waitForStdout('Waiting for file changes') | ||
vitest.resetOutput() | ||
|
||
// editing the root config should trigger a restart | ||
fs.editFile('./vitest.config.ts', c => `\n${c}`) | ||
|
||
await vitest.waitForStdout('Restarting due to config changes...') | ||
await vitest.waitForStdout('Waiting for file changes') | ||
vitest.resetOutput() | ||
|
||
// editing the workspace config should trigger a restart | ||
fs.editFile('./vitest.workspace.ts', c => `\n${c}`) | ||
|
||
await vitest.waitForStdout('Restarting due to config changes...') | ||
await vitest.waitForStdout('Waiting for file changes') | ||
}) | ||
|
||
test('rerun stops the previous browser server and restarts multiple times without port mismatch', async () => { | ||
const { fs, vitest } = await runInlineTests({ | ||
'vitest.workspace.ts': [ | ||
'./project-1', | ||
], | ||
'vitest.config.ts': {}, | ||
'project-1/vitest.config.ts': { | ||
test: { | ||
browser: { | ||
enabled: true, | ||
name: 'chromium', | ||
provider: 'playwright', | ||
headless: true, | ||
}, | ||
}, | ||
}, | ||
'project-1/basic.test.ts': ts` | ||
import { test } from 'vitest' | ||
test('basic test 1', () => {}) | ||
`, | ||
}, { watch: true }) | ||
|
||
await vitest.waitForStdout('Waiting for file changes') | ||
vitest.resetOutput() | ||
|
||
// editing the project config the first time restarts the browser server | ||
fs.editFile('./project-1/vitest.config.ts', c => `\n${c}`) | ||
|
||
await vitest.waitForStdout('Restarting due to config changes...') | ||
await vitest.waitForStdout('Waiting for file changes') | ||
|
||
expect(vitest.stdout).not.toContain('is in use, trying another one...') | ||
expect(vitest.stderr).not.toContain('is in use, trying another one...') | ||
vitest.resetOutput() | ||
|
||
// editing the project the second time also restarts the server | ||
fs.editFile('./project-1/vitest.config.ts', c => `\n${c}`) | ||
|
||
await vitest.waitForStdout('Restarting due to config changes...') | ||
await vitest.waitForStdout('Waiting for file changes') | ||
|
||
expect(vitest.stdout).not.toContain('is in use, trying another one...') | ||
expect(vitest.stderr).not.toContain('is in use, trying another one...') | ||
vitest.resetOutput() | ||
}) |
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
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