Skip to content

Commit d087f14

Browse files
committed
test: add expectBuildEnd log helper
1 parent d5c5598 commit d087f14

5 files changed

Lines changed: 29 additions & 6 deletions

File tree

packages/rstack/test/config/reload-app-config/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ define.app({
6666
);
6767

6868
execCliAsync('dev --config test-temp-import.config.ts');
69-
await logHelper.expectLog('built in');
69+
await logHelper.expectBuildEnd();
7070
logHelper.clearLogs();
7171

7272
await writeFile(importedFile, '// changed\n');

packages/rstack/test/helpers/cliTest.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { type ChildProcess, type SpawnOptions, spawn as nodeSpawn } from 'node:child_process';
22
import path from 'node:path';
3-
import {
4-
type ExtendedLogHelper,
5-
prepareDist as basePrepareDist,
6-
proxyConsole,
7-
} from '@rstackjs/test-utils';
3+
import { prepareDist as basePrepareDist } from '@rstackjs/test-utils';
84
import { test as baseTest } from 'rstack/test';
95
import { execCli as baseExecCli, type ExecCli, RSTACK_BIN_PATH } from './cli.ts';
6+
import { type ExtendedLogHelper, proxyConsole } from './logs.ts';
107

118
type Exec = (
129
command: string,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const BUILD_END_LOG = 'built in';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './cli.ts';
22
export * from './cliTest.ts';
3+
export * from './constants.ts';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
type ExtendedLogHelper as BaseExtendedLogHelper,
3+
type LogHelper as BaseLogHelper,
4+
proxyConsole as baseProxyConsole,
5+
type ProxyConsoleOptions,
6+
} from '@rstackjs/test-utils';
7+
import { BUILD_END_LOG } from './constants.ts';
8+
9+
type ExpectBuildEnd = {
10+
expectBuildEnd: () => Promise<boolean>;
11+
};
12+
13+
export type LogHelper = BaseLogHelper & ExpectBuildEnd;
14+
15+
export type ExtendedLogHelper = BaseExtendedLogHelper & ExpectBuildEnd;
16+
17+
export const proxyConsole = (options?: ProxyConsoleOptions): ExtendedLogHelper => {
18+
const logHelper = baseProxyConsole(options);
19+
20+
return {
21+
...logHelper,
22+
expectBuildEnd: async () => logHelper.expectLog(BUILD_END_LOG),
23+
};
24+
};

0 commit comments

Comments
 (0)