-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix: can not rerun all tests when has command filter #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a7435cd
fb90911
630b788
2d11b19
6786c84
bb88a0a
5733d6a
05bf43f
c63b627
faa1a75
19892c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { describe, expect, it } from '@rstest/core'; | ||
|
||
describe('Index1', () => { | ||
it('should add two numbers correctly', () => { | ||
expect(1 + 1).toBe(2); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,6 +26,20 @@ class TestFileWatchPlugin { | |||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const rstestVirtualEntryFlag = 'rstest-virtual-entry-'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
let rerunTrigger: Record<string, () => void> = {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const registerRerunTrigger = (name: string, fn: () => void) => { | ||||||||||||||||||||||||||||||||||||||||||||||
rerunTrigger[name] = fn; | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
export const triggerRerun = (): void => { | ||||||||||||||||||||||||||||||||||||||||||||||
Object.values(rerunTrigger).forEach((fn) => { | ||||||||||||||||||||||||||||||||||||||||||||||
fn(); | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
export const pluginEntryWatch: (params: { | ||||||||||||||||||||||||||||||||||||||||||||||
context: RstestContext; | ||||||||||||||||||||||||||||||||||||||||||||||
globTestSourceEntries: (name: string) => Promise<Record<string, string>>; | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -40,8 +54,16 @@ export const pluginEntryWatch: (params: { | |||||||||||||||||||||||||||||||||||||||||||||
}) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||
name: 'rstest:entry-watch', | ||||||||||||||||||||||||||||||||||||||||||||||
setup: (api) => { | ||||||||||||||||||||||||||||||||||||||||||||||
api.modifyRspackConfig(async (config, { environment }) => { | ||||||||||||||||||||||||||||||||||||||||||||||
api.onCloseDevServer(() => { | ||||||||||||||||||||||||||||||||||||||||||||||
rerunTrigger = {}; | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
api.modifyRspackConfig(async (config, { environment, rspack }) => { | ||||||||||||||||||||||||||||||||||||||||||||||
if (isWatch) { | ||||||||||||||||||||||||||||||||||||||||||||||
// FIXME: inspect config will retrigger initConfig | ||||||||||||||||||||||||||||||||||||||||||||||
if (rerunTrigger[environment.name]) { | ||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
config.plugins.push(new TestFileWatchPlugin(environment.config.root)); | ||||||||||||||||||||||||||||||||||||||||||||||
config.entry = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||
const sourceEntries = await globTestSourceEntries(environment.name); | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -51,7 +73,30 @@ export const pluginEntryWatch: (params: { | |||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// Add virtual entry to trigger recompile | ||||||||||||||||||||||||||||||||||||||||||||||
const virtualEntryName = `${rstestVirtualEntryFlag}${config.name!}.js`; | ||||||||||||||||||||||||||||||||||||||||||||||
const virtualEntryPath = `${environment.config.root}/${virtualEntryName}`; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const virtualModulesPlugin = | ||||||||||||||||||||||||||||||||||||||||||||||
new rspack.experiments.VirtualModulesPlugin({ | ||||||||||||||||||||||||||||||||||||||||||||||
[virtualEntryPath]: `export const virtualEntry = ${Date.now()}`, | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
registerRerunTrigger(environment.name, () => | ||||||||||||||||||||||||||||||||||||||||||||||
virtualModulesPlugin.writeModule( | ||||||||||||||||||||||||||||||||||||||||||||||
virtualEntryPath, | ||||||||||||||||||||||||||||||||||||||||||||||
`export const virtualEntry = ${Date.now()}`, | ||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as above - using
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
config.experiments ??= {}; | ||||||||||||||||||||||||||||||||||||||||||||||
config.experiments.nativeWatcher = true; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
config.plugins.push(virtualModulesPlugin); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
config.watchOptions ??= {}; | ||||||||||||||||||||||||||||||||||||||||||||||
config.watchOptions.aggregateTimeout = 5; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// TODO: rspack should support `(string | RegExp)[]` type | ||||||||||||||||||||||||||||||||||||||||||||||
// https://github.com/web-infra-dev/rspack/issues/10596 | ||||||||||||||||||||||||||||||||||||||||||||||
config.watchOptions.ignored = castArray( | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FIXME comment indicates a known issue but lacks detail about the problem and potential solutions. Consider expanding this comment to explain what 'inspect config will retrigger initConfig' means and its implications.
Copilot uses AI. Check for mistakes.