Skip to content

Commit aa6a4d9

Browse files
authored
test: optimize test logs (#979)
1 parent 36543d6 commit aa6a4d9

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

tests/integration/cli/build-watch/build.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export default defineConfig({
8383
index: ['./test-temp-src/**'],
8484
},
8585
},
86+
performance: {
87+
printFileSize: false,
88+
}
8689
});
8790
`,
8891
);

tests/integration/dts/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ describe('dts when bundle: false', () => {
7575
});
7676

7777
test('abortOnError: false', async () => {
78+
const { restore } = proxyConsole();
7879
const fixturePath = join(__dirname, 'bundle-false', 'abort-on-error');
7980
const { isSuccess } = await buildAndGetResults({
8081
fixturePath,
8182
type: 'dts',
8283
});
84+
restore();
8385

8486
expect(isSuccess).toBe(true);
8587
});
@@ -243,10 +245,12 @@ describe('dts when bundle: true', () => {
243245

244246
test('abortOnError: false', async () => {
245247
const fixturePath = join(__dirname, 'bundle', 'abort-on-error');
248+
const { restore } = proxyConsole();
246249
const { isSuccess } = await buildAndGetResults({
247250
fixturePath,
248251
type: 'dts',
249252
});
253+
restore();
250254

251255
expect(isSuccess).toBe(true);
252256
});
@@ -478,10 +482,12 @@ describe('dts when build: true', () => {
478482

479483
test('abortOnError: false', async () => {
480484
const fixturePath = join(__dirname, 'build', 'abort-on-error');
485+
const { restore } = proxyConsole();
481486
const { isSuccess } = await buildAndGetResults({
482487
fixturePath,
483488
type: 'dts',
484489
});
490+
restore();
485491

486492
expect(isSuccess).toBe(true);
487493

@@ -566,10 +572,12 @@ describe('dts when composite: true', () => {
566572

567573
test('abortOnError: false', async () => {
568574
const fixturePath = join(__dirname, 'composite', 'abort-on-error');
575+
const { restore } = proxyConsole();
569576
const { isSuccess } = await buildAndGetResults({
570577
fixturePath,
571578
type: 'dts',
572579
});
580+
restore();
573581

574582
expect(isSuccess).toBe(true);
575583

tests/integration/externals/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import { composeModuleImportWarn } from '../../../packages/core/src/config';
66

77
test('should fail to build when `output.target` is not "node"', async () => {
88
const fixturePath = join(__dirname, 'browser');
9+
const { restore } = proxyConsole();
910
const build = buildAndGetResults({ fixturePath });
1011
await expect(build).rejects.toThrowError('Rspack build failed.');
12+
restore();
1113
});
1214

1315
test('auto externalize Node.js built-in modules when `output.target` is "node"', async () => {
1416
const fixturePath = join(__dirname, 'node');
17+
const { restore } = proxyConsole();
1518
const { entries } = await buildAndGetResults({ fixturePath });
19+
restore();
1620

1721
for (const external of [
1822
'import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs"',
@@ -70,7 +74,9 @@ test('should get warn when use require in ESM', async () => {
7074

7175
test('require ESM from CJS', async () => {
7276
const fixturePath = join(__dirname, 'node');
77+
const { restore } = proxyConsole();
7378
const { entryFiles } = await buildAndGetResults({ fixturePath });
79+
restore();
7480
const baz = (await import(entryFiles.cjs)).baz;
7581
const bazValue = await baz();
7682
expect(bazValue).toBe('baz');

tests/integration/redirect/dts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let contents: Awaited<ReturnType<typeof buildAndGetResults>>['contents'];
77
beforeAll(async () => {
88
const fixturePath = path.resolve(__dirname, './dts');
99
contents = (await buildAndGetResults({ fixturePath, type: 'dts' })).contents;
10-
}, 15000);
10+
}, 20000);
1111

1212
test('redirect.dts.path: true with redirect.dts.extension: false - default', async () => {
1313
expect(contents.esm0).toMatchInlineSnapshot(`

tests/scripts/shared.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ export async function getResults(
190190
};
191191
}
192192

193+
const updateConfigForTest = (rslibConfig: RslibConfig) => {
194+
Object.assign(rslibConfig, {
195+
performance: {
196+
// Do not print file size in tests
197+
printFileSize: false,
198+
},
199+
});
200+
};
201+
193202
export async function rslibBuild({
194203
cwd,
195204
path,
@@ -241,6 +250,7 @@ export async function buildAndGetResults({
241250
const { rsbuildInstance, rslibConfig } = await rslibBuild({
242251
cwd: fixturePath,
243252
path: configPath,
253+
modifyConfig: updateConfigForTest,
244254
lib,
245255
});
246256
const {

0 commit comments

Comments
 (0)