Skip to content

Commit c3bfa02

Browse files
authored
test: add entry tests (#134)
1 parent b9bc60d commit c3bfa02

File tree

19 files changed

+145
-2
lines changed

19 files changed

+145
-2
lines changed

e2e/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Rslib will try to cover the common scenarios in the [integration test cases of M
2424
| esbuildOptions | ⚫️ | |
2525
| externals | 🟢 | |
2626
| format | 🟡 | Support `cjs` and `esm`, `umd` still need to be tested |
27-
| input | ⚪️ | |
27+
| input | 🟢 | |
2828
| jsx | ⚪️ | |
2929
| metafile | ⚪️ | |
30-
| minify | ⚪️ | |
30+
| minify | 🟢 | |
3131
| platform | 🟢 | |
3232
| redirect | ⚪️ | |
3333
| resolve | ⚪️ | |

e2e/cases/entry/glob/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "entry-glob-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig({
7+
bundle: false,
8+
}),
9+
generateBundleCjsConfig({
10+
bundle: false,
11+
}),
12+
],
13+
source: {
14+
entry: {
15+
index: ['./src/**', '!**/*.ignore.ts'],
16+
},
17+
},
18+
});

e2e/cases/entry/glob/src/bar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const bar = 'bar';
2+
console.log('bar: ', bar);

e2e/cases/entry/glob/src/foo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'foo';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function () {
2+
return 'ignore baz';
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function () {
2+
return 'ignore index';
3+
}

e2e/cases/entry/glob/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { foo } from './foo';
2+
3+
export const text = () => `hello ${foo}`;

e2e/cases/entry/index.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { join } from 'node:path';
2+
import { buildAndGetResults } from '@e2e/helper';
3+
import { expect, test } from 'vitest';
4+
5+
test('single entry bundle', async () => {
6+
const fixturePath = join(__dirname, 'single');
7+
const { files } = await buildAndGetResults(fixturePath);
8+
9+
expect(files).toMatchInlineSnapshot(`
10+
{
11+
"cjs": [
12+
"<ROOT>/e2e/cases/entry/single/dist/cjs/index.cjs",
13+
],
14+
"esm": [
15+
"<ROOT>/e2e/cases/entry/single/dist/esm/index.js",
16+
],
17+
}
18+
`);
19+
});
20+
21+
test('multiple entry bundle', async () => {
22+
const fixturePath = join(__dirname, 'multiple');
23+
const { files } = await buildAndGetResults(fixturePath);
24+
25+
expect(files).toMatchInlineSnapshot(`
26+
{
27+
"cjs": [
28+
"<ROOT>/e2e/cases/entry/multiple/dist/cjs/bar.cjs",
29+
"<ROOT>/e2e/cases/entry/multiple/dist/cjs/index.cjs",
30+
],
31+
"esm": [
32+
"<ROOT>/e2e/cases/entry/multiple/dist/esm/bar.js",
33+
"<ROOT>/e2e/cases/entry/multiple/dist/esm/index.js",
34+
],
35+
}
36+
`);
37+
});
38+
39+
test('glob entry bundleless', async () => {
40+
const fixturePath = join(__dirname, 'glob');
41+
const { files } = await buildAndGetResults(fixturePath);
42+
43+
expect(files).toMatchInlineSnapshot(`
44+
{
45+
"cjs": [
46+
"<ROOT>/e2e/cases/entry/glob/dist/cjs/bar.cjs",
47+
"<ROOT>/e2e/cases/entry/glob/dist/cjs/foo.cjs",
48+
"<ROOT>/e2e/cases/entry/glob/dist/cjs/index.cjs",
49+
],
50+
"esm": [
51+
"<ROOT>/e2e/cases/entry/glob/dist/esm/bar.js",
52+
"<ROOT>/e2e/cases/entry/glob/dist/esm/foo.js",
53+
"<ROOT>/e2e/cases/entry/glob/dist/esm/index.js",
54+
],
55+
}
56+
`);
57+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "entry-multiple-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}

0 commit comments

Comments
 (0)