Skip to content

Commit f1a467f

Browse files
authored
test: add copy tests (#136)
1 parent c3bfa02 commit f1a467f

File tree

14 files changed

+123
-1
lines changed

14 files changed

+123
-1
lines changed

e2e/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Rslib will try to cover the common scenarios in the [integration test cases of M
1616
| autoExternal | 🟢 | |
1717
| banner-footer | ⚪️ | |
1818
| buildType | 🟢 | |
19-
| copy | ⚪️ | |
19+
| copy | 🟢 | |
2020
| decorator | ⚪️ | |
2121
| define | 🟢 | |
2222
| dts | 🟢 | |

e2e/cases/copy/index.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { join } from 'node:path';
2+
import { buildAndGetResults, generateFileTree } from '@e2e/helper';
3+
import { expect, test } from 'vitest';
4+
5+
test('copy', async () => {
6+
const fixturePath = __dirname;
7+
await buildAndGetResults(fixturePath);
8+
9+
const fileTree = generateFileTree(join(fixturePath, './dist/esm'));
10+
expect(fileTree).toMatchInlineSnapshot(`
11+
{
12+
"index.js": "<ROOT>/e2e/cases/copy/dist/esm/index.js",
13+
"temp-1": {
14+
"b.png": "<ROOT>/e2e/cases/copy/dist/esm/temp-1/b.png",
15+
},
16+
"temp-2": {
17+
"a.png": "<ROOT>/e2e/cases/copy/dist/esm/temp-2/a.png",
18+
},
19+
"temp-3": {
20+
"a.png": "<ROOT>/e2e/cases/copy/dist/esm/temp-3/a.png",
21+
"b.txt": "<ROOT>/e2e/cases/copy/dist/esm/temp-3/b.txt",
22+
},
23+
"temp-4": {
24+
"_index.html": "<ROOT>/e2e/cases/copy/dist/esm/temp-4/_index.html",
25+
},
26+
"temp-5": {
27+
"index.html": "<ROOT>/e2e/cases/copy/dist/esm/temp-5/index.html",
28+
},
29+
"temp-6": {
30+
"index.html": "<ROOT>/e2e/cases/copy/dist/esm/temp-6/index.html",
31+
},
32+
}
33+
`);
34+
});

e2e/cases/copy/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "copy-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}

e2e/cases/copy/rslib.config.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig({
7+
output: {
8+
copy: [
9+
/**
10+
* copy file to file
11+
*/
12+
{
13+
from: './temp-1/a.png',
14+
to: 'temp-1/b.png',
15+
},
16+
/**
17+
* copy file to dir
18+
*/
19+
{
20+
from: './temp-2/a.png',
21+
to: 'temp-2',
22+
},
23+
/**
24+
* copy dir to dir
25+
*/
26+
{
27+
from: './temp-3/',
28+
to: 'temp-3',
29+
},
30+
/**
31+
* copy dir to file
32+
*/
33+
{
34+
from: './temp-4/',
35+
to: 'temp-4/_index.html',
36+
},
37+
/**
38+
* copy glob to dir
39+
*/
40+
{
41+
from: './*.html',
42+
context: 'temp-4',
43+
to: 'temp-5',
44+
},
45+
/**
46+
* copy glob to file
47+
*/
48+
{
49+
from: './temp-4/*.html',
50+
to: 'temp-6/index.html',
51+
},
52+
],
53+
},
54+
}),
55+
],
56+
});

e2e/cases/copy/src/index.html

Whitespace-only changes.

e2e/cases/copy/src/index.ts

Whitespace-only changes.

e2e/cases/copy/src/test.txt

Whitespace-only changes.

e2e/cases/copy/temp-1/a.png

Loading

e2e/cases/copy/temp-2/a.png

Loading

e2e/cases/copy/temp-3/a.png

Loading

0 commit comments

Comments
 (0)