-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.ts
57 lines (46 loc) · 1.53 KB
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as path from 'node:path';
import * as fs from 'node:fs';
import { Locals, Shell } from '@deot/dev-shared';
import * as Builder from '@deot/dev-builder';
// @vitest-environment node
describe('index', () => {
it('config', () => {
const it = Locals.impl();
expect(it.cwd).toMatch('/dev');
});
it('run', async () => {
expect(typeof Builder.run).toBe('function');
});
it('monorepo', async () => {
expect.assertions(4);
const response = await Shell.spawn(`npm`, ['run', 'build'], {
cwd: path.resolve('./packages/_/monorepo'),
stdio: 'pipe'
});
const has = (filename: string) => fs.existsSync(path.resolve(`./packages/_/monorepo/packages/components/dist/`, filename));
expect(response).toBe(0);
expect(has('index.es.js')).toBe(true);
expect(has('index.cjs')).toBe(true);
expect(has('index.d.ts')).toBe(true);
}, 120000);
it('singlerepo', async () => {
expect.assertions(7);
const response = await Shell.spawn(`npm`, ['run', 'build'], {
cwd: path.resolve('./packages/_/singlerepo'),
stdio: 'pipe'
});
expect(response).toBe(0);
const has = (filename: string) => fs.existsSync(path.resolve('./packages/_/singlerepo/dist/', filename));
expect(has('index.css')).toBe(true);
// 因为js引用了css,vite会将其打包出,命名为style.css
expect(has('style.css')).toBe(true);
// es
expect(has('index.es.js')).toBe(true);
// cjs
expect(has('index.cjs')).toBe(true);
// iife
expect(has('index.iife.js')).toBe(true);
// umd
expect(has('index.umd.js')).toBe(true);
}, 120000);
});