Skip to content

Commit 56e1bde

Browse files
committed
test: add initial tests for define.lib
1 parent 59ed2b2 commit 56e1bde

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { rm } from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { expect, test } from 'rstack/test';
4+
import { execCli, getDistFiles, getFileContent } from '#test-helpers';
5+
6+
const cwd = import.meta.dirname;
7+
const expectedText = 'define.lib works';
8+
9+
test('should build lib with define.lib config', async () => {
10+
const distPath = path.join(cwd, 'dist');
11+
await rm(distPath, { recursive: true, force: true });
12+
13+
execCli(['lib'], { cwd });
14+
15+
const files = await getDistFiles(distPath);
16+
const output = getFileContent(files, 'index.js');
17+
18+
expect(output).toContain(expectedText);
19+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"private": true,
3+
"type": "module"
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { define } from 'rstack';
2+
3+
define.lib({
4+
lib: [{}],
5+
source: {
6+
define: {
7+
DEFINE_LIB_TEST_VALUE: JSON.stringify('define.lib works'),
8+
},
9+
},
10+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const message = DEFINE_LIB_TEST_VALUE;

0 commit comments

Comments
 (0)