-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathutils.spec.ts
More file actions
86 lines (76 loc) · 3.18 KB
/
utils.spec.ts
File metadata and controls
86 lines (76 loc) · 3.18 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { tmpdir } from 'node:os';
import { describe, expect, test } from '@voidzero-dev/vite-plus/test';
import { replaceUnstableOutput } from '../utils.ts';
describe('replaceUnstableOutput', () => {
test('replace unstable semver version', () => {
const output = `
foo v1.0.0
v1.0.0-beta.1
v1.0.0-beta.1+build.1
1.0.0
1.0.0-beta.1
1.0.0-beta.1+build.1
tsdown/0.15.1
vitest/3.2.4
foo/v100.1.1000
foo@1.0.0
bar@v1.0.0
`;
expect(replaceUnstableOutput(output.trim())).toMatchSnapshot();
});
test('replace date', () => {
const output = `
Start at 15:01:23
15:01:23
`;
expect(replaceUnstableOutput(output.trim())).toMatchSnapshot();
});
test('replace unstable pnpm install output', () => {
const outputs = [
`
Scope: all 6 workspace projects
Packages: +312
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 316, reused 316, downloaded 0, added 315
WARN Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use \`pnpm update\` to update the catalogs.
WARN Skip adding vitest to the default catalog because it already exists as beta. Please use \`pnpm update\` to update the catalogs.
Progress: resolved 316, reused 316, downloaded 0, added 316, done
devDependencies:
+ @voidzero-dev/vite-plus 0.0.0-8a4f4936e0eca32dd57e1a503c2b09745953344d
+ vitest 3.2.4
`,
`
Scope: all 2 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
╭ Warning ───────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Ignored build scripts: esbuild. │
│ Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts. │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
Done in 171ms using pnpm v10.16.1
`,
];
for (const output of outputs) {
expect(replaceUnstableOutput(output.trim())).toMatchSnapshot();
}
});
test('replace unstable cwd', () => {
const cwd = tmpdir();
const output = `${cwd}/foo.txt`;
expect(replaceUnstableOutput(output.trim(), cwd)).toMatchSnapshot();
});
test('replace tsdown output', () => {
const output = `
ℹ tsdown v0.15.1 powered by rolldown v0.15.1
ℹ entry: src/index.ts
ℹ Build start
ℹ dist/index.js 0.15 kB │ gzip: 0.12 kB
ℹ 1 files, total: 0.15 kB
✔ Build complete in 100ms
`;
expect(replaceUnstableOutput(output.trim())).toMatchSnapshot();
});
});