|
| 1 | +import { tmpdir } from 'node:os'; |
| 2 | + |
| 3 | +import { describe, expect, test } from 'vitest'; |
| 4 | + |
| 5 | +import { replaceUnstableOutput } from '../utils.ts'; |
| 6 | + |
| 7 | +describe('replaceUnstableOutput', () => { |
| 8 | + test('replace unstable semver version', () => { |
| 9 | + const output = ` |
| 10 | +v1.0.0 |
| 11 | +v1.0.0-beta.1 |
| 12 | +v1.0.0-beta.1+build.1 |
| 13 | +1.0.0 |
| 14 | +1.0.0-beta.1 |
| 15 | +1.0.0-beta.1+build.1 |
| 16 | + `; |
| 17 | + expect(replaceUnstableOutput(output.trim())).toMatchSnapshot(); |
| 18 | + }); |
| 19 | + |
| 20 | + test('replace unstable pnpm install output', () => { |
| 21 | + const outputs = [ |
| 22 | + ` |
| 23 | +Scope: all 6 workspace projects |
| 24 | +Packages: +312 |
| 25 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 26 | +Progress: resolved 1, reused 0, downloaded 0, added 0 |
| 27 | +Progress: resolved 316, reused 316, downloaded 0, added 315 |
| 28 | +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. |
| 29 | +WARN Skip adding vitest to the default catalog because it already exists as beta. Please use \`pnpm update\` to update the catalogs. |
| 30 | +Progress: resolved 316, reused 316, downloaded 0, added 316, done |
| 31 | +
|
| 32 | +devDependencies: |
| 33 | ++ @voidzero-dev/vite-plus 0.0.0-8a4f4936e0eca32dd57e1a503c2b09745953344d |
| 34 | ++ vitest 3.2.4 |
| 35 | + `, |
| 36 | + ` |
| 37 | +Scope: all 2 workspace projects |
| 38 | +Lockfile is up to date, resolution step is skipped |
| 39 | +Already up to date |
| 40 | +
|
| 41 | +╭ Warning ───────────────────────────────────────────────────────────────────────────────────╮ |
| 42 | +│ │ |
| 43 | +│ Ignored build scripts: esbuild. │ |
| 44 | +│ Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts. │ |
| 45 | +│ │ |
| 46 | +╰────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 47 | +
|
| 48 | +Done in 171ms using pnpm v10.16.1 |
| 49 | + `, |
| 50 | + ]; |
| 51 | + for (const output of outputs) { |
| 52 | + expect(replaceUnstableOutput(output.trim())).toMatchSnapshot(); |
| 53 | + } |
| 54 | + }); |
| 55 | + |
| 56 | + test('replace unstable cwd', () => { |
| 57 | + const cwd = tmpdir(); |
| 58 | + const output = `${cwd}/foo.txt`; |
| 59 | + expect(replaceUnstableOutput(output.trim(), cwd)).toMatchSnapshot(); |
| 60 | + }); |
| 61 | +}); |
0 commit comments