Skip to content

Commit

Permalink
test: avoid potential output conflict (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework authored Nov 27, 2024
1 parent 00c0d3a commit 8ef44bc
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 32 deletions.
6 changes: 4 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('build command', async () => {
const fileNames = Object.keys(files).sort();
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/cjs/index.cjs",
"<ROOT>/tests/integration/cli/dist/esm/index.js",
"<ROOT>/tests/integration/cli/build/dist/cjs/index.cjs",
"<ROOT>/tests/integration/cli/build/dist/esm/index.js",
]
`);
});
Expand All @@ -31,7 +31,7 @@ describe('build command', async () => {
const fileNames = Object.keys(files).sort();
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/esm/index.js",
"<ROOT>/tests/integration/cli/build/dist/esm/index.js",
]
`);
});
Expand All @@ -46,8 +46,8 @@ describe('build command', async () => {
const fileNames = Object.keys(files).sort();
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/cjs/index.cjs",
"<ROOT>/tests/integration/cli/dist/esm/index.js",
"<ROOT>/tests/integration/cli/build/dist/cjs/index.cjs",
"<ROOT>/tests/integration/cli/build/dist/esm/index.js",
]
`);
});
Expand All @@ -65,15 +65,14 @@ describe('build command', async () => {
const fileNames = Object.keys(files).sort();
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/custom/index.cjs",
"<ROOT>/tests/integration/cli/dist/custom/index.js",
"<ROOT>/tests/integration/cli/build/dist/custom/index.cjs",
"<ROOT>/tests/integration/cli/build/dist/custom/index.js",
]
`);
});

test('--root', async () => {
await fse.remove(path.join(__dirname, 'dist'));
console.log('__dirname: ', __dirname);
execSync('npx rslib build --root custom-root', {
cwd: __dirname,
});
Expand All @@ -82,8 +81,8 @@ describe('build command', async () => {
const fileNames = Object.keys(files).sort();
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/root/index.cjs",
"<ROOT>/tests/integration/cli/dist/root/index.js",
"<ROOT>/tests/integration/cli/build/dist/root/index.cjs",
"<ROOT>/tests/integration/cli/build/dist/root/index.js",
]
`);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cli-test",
"name": "cli-build-test",
"version": "1.0.0",
"private": true,
"type": "module"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe('inspect command', async () => {
const fileNames = Object.keys(files).sort();

expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.cjs.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.esm.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.cjs.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.esm.mjs",
]
`);
[
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rsbuild.config.cjs.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rsbuild.config.esm.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rspack.config.cjs.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rspack.config.esm.mjs",
]
`);

// esm rsbuild config
const rsbuildConfigEsm = fileNames.find((item) =>
Expand Down Expand Up @@ -52,11 +52,11 @@ describe('inspect command', async () => {

// Rsbuild will emit dump files to `dist/esm` if only one environment is specified.
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/esm/.rsbuild/rsbuild.config.mjs",
"<ROOT>/tests/integration/cli/dist/esm/.rsbuild/rspack.config.esm.mjs",
]
`);
[
"<ROOT>/tests/integration/cli/inspect/dist/esm/.rsbuild/rsbuild.config.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/esm/.rsbuild/rspack.config.esm.mjs",
]
`);

// esm rsbuild config
const rsbuildConfigEsm = fileNames.find((item) =>
Expand Down Expand Up @@ -84,12 +84,12 @@ describe('inspect command', async () => {

// Rsbuild will emit dump files to `dist/esm` if only one environment is specified.
expect(fileNames).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.cjs.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.esm.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.cjs.mjs",
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.esm.mjs",
]
`);
[
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rsbuild.config.cjs.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rsbuild.config.esm.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rspack.config.cjs.mjs",
"<ROOT>/tests/integration/cli/inspect/dist/.rsbuild/rspack.config.esm.mjs",
]
`);
});
});
6 changes: 6 additions & 0 deletions tests/integration/cli/inspect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "cli-inspect-test",
"version": "1.0.0",
"private": true,
"type": "module"
}
6 changes: 6 additions & 0 deletions tests/integration/cli/inspect/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [generateBundleEsmConfig(), generateBundleCjsConfig()],
});
1 change: 1 addition & 0 deletions tests/integration/cli/inspect/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = 'foo';

0 comments on commit 8ef44bc

Please sign in to comment.