Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
setup() {}
}
],
logLevel: undefined
logLevel: 'silent'
}"
`;

Expand Down
1 change: 1 addition & 0 deletions packages/core/tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ describe('Should compose create Rsbuild config correctly', () => {
},
},
},
logLevel: 'silent',
};
const composedRsbuildConfig = await composeCreateRsbuildConfig(rslibConfig);
expect(composedRsbuildConfig).toMatchSnapshot();
Expand Down
7 changes: 3 additions & 4 deletions tests/integration/cli/build-watch/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { spawn } from 'node:child_process';
import path from 'node:path';
import { after } from 'node:test';
import { describe, expect, test } from '@rstest/core';
import { describe, expect, onTestFinished, test } from '@rstest/core';
import fse from 'fs-extra';
import {
expectFile,
Expand Down Expand Up @@ -107,7 +106,7 @@ export default defineConfig({
[rslibBinPath, 'build', '--watch', '-c', tempConfigFile],
{
cwd: __dirname,
stdio: 'inherit',
stdio: 'pipe',
shell: true,
},
);
Expand Down Expand Up @@ -144,7 +143,7 @@ export default defineConfig({
"
`);

after(() => {
onTestFinished(() => {
child.kill();
});
});
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cli/inspect/inspect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'node:path';
import { describe } from 'node:test';
import { expect, test } from '@rstest/core';
import { describe, expect, test } from '@rstest/core';
import fse from 'fs-extra';
import { globContentJSON, runCliSync } from 'test-helper';

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cli/log-level/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe } from 'node:test';
import { stripVTControlCharacters as stripAnsi } from 'node:util';
import { expect, test } from '@rstest/core';
import { describe, expect, test } from '@rstest/core';
import { runCliSync } from 'test-helper';

describe('log level', async () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cli/mf/mf.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { join } from 'node:path';
import { describe } from 'node:test';
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
import { startMFDevServer } from '@rslib/core';
import { expect, test } from '@rstest/core';
import { describe, expect, test } from '@rstest/core';
import fse from 'fs-extra';
import { expectFile, runCli, runCliSync } from 'test-helper';

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/entry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test('validate entry and throw errors', async () => {
test('duplicate entry in bundleless mode', async () => {
const { logs, restore } = proxyConsole();
const fixturePath = join(__dirname, 'duplicate');
await buildAndGetResults({ fixturePath });
await buildAndGetResults({ fixturePath, logLevel: 'info' });

const logStrings = logs.map((log) => stripAnsi(log));

Expand Down
25 changes: 16 additions & 9 deletions tests/scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { fileURLToPath } from 'node:url';
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
import {
type InspectConfigResult,
type LogLevel,
mergeRsbuildConfig as mergeConfig,
} from '@rsbuild/core';
import type { Format, LibConfig, RslibConfig } from '@rslib/core';
Expand Down Expand Up @@ -223,14 +224,16 @@ export async function getResults(
};
}

const updateConfigForTest = (rslibConfig: RslibConfig) => {
Object.assign(rslibConfig, {
performance: {
// Do not print file size in tests
printFileSize: false,
},
});
};
const updateConfigForTest =
(logLevel?: LogLevel) => (rslibConfig: RslibConfig) => {
Object.assign(rslibConfig, {
performance: {
// Do not print file size in tests
printFileSize: false,
},
logLevel,
});
};

export async function rslibBuild({
cwd,
Expand Down Expand Up @@ -258,6 +261,7 @@ export async function buildAndGetResults(options: {
configPath?: string;
type: 'all';
lib?: string[];
logLevel?: LogLevel;
}): Promise<{
js: BuildResult;
dts: BuildResult;
Expand All @@ -268,22 +272,25 @@ export async function buildAndGetResults(options: {
configPath?: string;
type?: 'js' | 'dts' | 'css';
lib?: string[];
logLevel?: LogLevel;
}): Promise<BuildResult>;
export async function buildAndGetResults({
fixturePath,
configPath,
type = 'js',
lib,
logLevel = 'warn',
}: {
fixturePath: string;
configPath?: string;
type?: 'js' | 'dts' | 'css' | 'all';
lib?: string[];
logLevel?: LogLevel;
}) {
const { rsbuildInstance, rslibConfig } = await rslibBuild({
cwd: fixturePath,
path: configPath,
modifyConfig: updateConfigForTest,
modifyConfig: updateConfigForTest(logLevel),
lib,
});
const {
Expand Down
Loading