Skip to content

Commit f83c7ef

Browse files
authored
fix: inaccurate build time in watch mode (#659)
1 parent e89ab63 commit f83c7ef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/src/core/runTests.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ export async function runTests(context: Rstest): Promise<void> {
120120
const run = async ({
121121
fileFilters,
122122
mode = 'all',
123+
buildStart = Date.now(),
123124
}: {
124125
fileFilters?: string[];
125126
mode?: Mode;
127+
buildStart?: number;
126128
} = {}) => {
127129
let testStart: number;
128-
const buildStart = Date.now();
129130
const currentEntries: EntryInfo[] = [];
130131
const currentDeletedEntries: string[] = [];
131132

@@ -314,15 +315,19 @@ export async function runTests(context: Rstest): Promise<void> {
314315
await closeServer();
315316
});
316317

318+
let buildStart: number | undefined;
319+
317320
rsbuildInstance.onBeforeDevCompile(({ isFirstCompile }) => {
321+
buildStart = Date.now();
318322
if (!isFirstCompile) {
319323
clearScreen();
320324
}
321325
});
322326

323327
rsbuildInstance.onAfterDevCompile(async ({ isFirstCompile }) => {
324328
snapshotManager.clear();
325-
await run({ mode: isFirstCompile ? 'all' : 'on-demand' });
329+
await run({ buildStart, mode: isFirstCompile ? 'all' : 'on-demand' });
330+
buildStart = undefined;
326331

327332
if (isFirstCompile && enableCliShortcuts) {
328333
const closeCliShortcuts = await setupCliShortcuts({

0 commit comments

Comments
 (0)