Skip to content

Commit 489b1b0

Browse files
authored
Migrate to Vitest (#249)
* Migrate to vitest * Format
1 parent 456ca21 commit 489b1b0

15 files changed

+599
-1273
lines changed

package.json

+3-11
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
"postinstall": "preconstruct dev && NODE_OPTIONS=--experimental-strip-types packages/cli/bin.js check",
1414
"knip": "knip",
1515
"release": "preconstruct build && changeset publish",
16-
"test": "jest",
16+
"test": "vitest",
1717
"test-gatsby": "cd test-gatsby && gatsby develop"
1818
},
19-
"jest": {
20-
"watchPlugins": [
21-
"jest-watch-typeahead/filename",
22-
"jest-watch-typeahead/testname"
23-
]
24-
},
2519
"devDependencies": {
2620
"@babel/core": "^7.20.5",
2721
"@babel/plugin-transform-runtime": "^7.19.6",
@@ -30,16 +24,14 @@
3024
"@changesets/changelog-github": "^0.4.8",
3125
"@changesets/cli": "^2.26.0",
3226
"@preconstruct/cli": "^2.8.12",
33-
"@types/jest": "^29.2.4",
3427
"@types/normalize-path": "^3.0.0",
3528
"@types/parse-github-url": "^1.0.0",
3629
"@types/semver": "^6.0.1",
37-
"jest": "^29.3.1",
38-
"jest-watch-typeahead": "^2.2.1",
3930
"knip": "^5.33.3",
4031
"prettier": "^3.5.3",
4132
"prettier-plugin-packagejson": "^2.5.10",
42-
"typescript": "^5.3.2"
33+
"typescript": "^5.3.2",
34+
"vitest": "^3.1.2"
4335
},
4436
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
4537
"preconstruct": {

packages/cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"@changesets/types": "^5.2.1",
3333
"@types/validate-npm-package-name": "^4.0.2",
3434
"fixturez": "^1.1.0",
35-
"strip-ansi": "^6.0.0"
35+
"strip-ansi": "^6.0.0",
36+
"vitest": "^3.1.2"
3637
},
3738
"engines": {
3839
"node": ">=18.0.0"

packages/cli/src/__snapshots__/run.test.ts.snap

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,131 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Run command should execute "@manypkg/basic-fixture-pkg-two start" and exit with 0: stderr 1`] = `
3+
exports[`Run command > should execute "@manypkg/basic-fixture-pkg-two start" and exit with 0 > stderr 1`] = `
44
"warning package.json: No license field
55
warning ../../package.json: No license field
66
"
77
`;
88

9-
exports[`Run command should execute "@manypkg/basic-fixture-pkg-two start" and exit with 0: stdout 1`] = `
9+
exports[`Run command > should execute "@manypkg/basic-fixture-pkg-two start" and exit with 0 > stdout 1`] = `
1010
"$ echo hello start
1111
hello start
1212
"
1313
`;
1414

15-
exports[`Run command should execute "package start" and exit with 1: stderr 1`] = `
15+
exports[`Run command > should execute "package start" and exit with 1 > stderr 1`] = `
1616
"☔️ error an identifier must only match a single package but "package" matches the following packages:
1717
☔️ error @manypkg/basic-fixture-pkg-one
1818
☔️ error @manypkg/basic-fixture-pkg-two
1919
☔️ error @manypkg/basic-fixture-pkg-two-one
2020
"
2121
`;
2222

23-
exports[`Run command should execute "package start" and exit with 1: stdout 1`] = `""`;
23+
exports[`Run command > should execute "package start" and exit with 1 > stdout 1`] = `""`;
2424

25-
exports[`Run command should execute "package-one start" and exit with 0: stderr 1`] = `
25+
exports[`Run command > should execute "package-one start" and exit with 0 > stderr 1`] = `
2626
"warning package.json: No license field
2727
warning ../../package.json: No license field
2828
"
2929
`;
3030

31-
exports[`Run command should execute "package-one start" and exit with 0: stdout 1`] = `
31+
exports[`Run command > should execute "package-one start" and exit with 0 > stdout 1`] = `
3232
"$ echo hello start
3333
hello start
3434
"
3535
`;
3636

37-
exports[`Run command should execute "package-one test" and exit with 0: stderr 1`] = `
37+
exports[`Run command > should execute "package-one test" and exit with 0 > stderr 1`] = `
3838
"warning package.json: No license field
3939
warning ../../package.json: No license field
4040
"
4141
`;
4242

43-
exports[`Run command should execute "package-one test" and exit with 0: stdout 1`] = `
43+
exports[`Run command > should execute "package-one test" and exit with 0 > stdout 1`] = `
4444
"$ echo testing
4545
testing
4646
"
4747
`;
4848

49-
exports[`Run command should execute "package-three start" and exit with 1: stderr 1`] = `
49+
exports[`Run command > should execute "package-three start" and exit with 1 > stderr 1`] = `
5050
"☔️ error No matching packages found
5151
"
5252
`;
5353

54-
exports[`Run command should execute "package-three start" and exit with 1: stdout 1`] = `""`;
54+
exports[`Run command > should execute "package-three start" and exit with 1 > stdout 1`] = `""`;
5555

56-
exports[`Run command should execute "package-two start" and exit with 1: stderr 1`] = `
56+
exports[`Run command > should execute "package-two start" and exit with 1 > stderr 1`] = `
5757
"☔️ error an identifier must only match a single package but "package-two" matches the following packages:
5858
☔️ error @manypkg/basic-fixture-pkg-two
5959
☔️ error @manypkg/basic-fixture-pkg-two-one
6060
"
6161
`;
6262

63-
exports[`Run command should execute "package-two start" and exit with 1: stdout 1`] = `""`;
63+
exports[`Run command > should execute "package-two start" and exit with 1 > stdout 1`] = `""`;
6464

65-
exports[`Run command should execute "package-two-one something" and exit with 1: stderr 1`] = `
65+
exports[`Run command > should execute "package-two-one something" and exit with 1 > stderr 1`] = `
6666
"warning package.json: No license field
6767
warning ../../package.json: No license field
6868
error Command "something" not found.
6969
"
7070
`;
7171

72-
exports[`Run command should execute "package-two-one something" and exit with 1: stdout 1`] = `
72+
exports[`Run command > should execute "package-two-one something" and exit with 1 > stdout 1`] = `
7373
"info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7474
"
7575
`;
7676

77-
exports[`Run command should execute "package-two-one start" and exit with 0: stderr 1`] = `
77+
exports[`Run command > should execute "package-two-one start" and exit with 0 > stderr 1`] = `
7878
"warning package.json: No license field
7979
warning ../../package.json: No license field
8080
"
8181
`;
8282

83-
exports[`Run command should execute "package-two-one start" and exit with 0: stdout 1`] = `
83+
exports[`Run command > should execute "package-two-one start" and exit with 0 > stdout 1`] = `
8484
"$ echo hello start
8585
hello start
8686
"
8787
`;
8888

89-
exports[`Run command should execute "packages/package-two start" and exit with 0: stderr 1`] = `
89+
exports[`Run command > should execute "packages/package-two start" and exit with 0 > stderr 1`] = `
9090
"warning package.json: No license field
9191
warning ../../package.json: No license field
9292
"
9393
`;
9494

95-
exports[`Run command should execute "packages/package-two start" and exit with 0: stdout 1`] = `
95+
exports[`Run command > should execute "packages/package-two start" and exit with 0 > stdout 1`] = `
9696
"$ echo hello start
9797
hello start
9898
"
9999
`;
100100

101-
exports[`Run command should execute "pkg-one start" and exit with 0: stderr 1`] = `
101+
exports[`Run command > should execute "pkg-one start" and exit with 0 > stderr 1`] = `
102102
"warning package.json: No license field
103103
warning ../../package.json: No license field
104104
"
105105
`;
106106

107-
exports[`Run command should execute "pkg-one start" and exit with 0: stdout 1`] = `
107+
exports[`Run command > should execute "pkg-one start" and exit with 0 > stdout 1`] = `
108108
"$ echo hello start
109109
hello start
110110
"
111111
`;
112112

113-
exports[`Run command should execute "pkg-two start" and exit with 1: stderr 1`] = `
113+
exports[`Run command > should execute "pkg-two start" and exit with 1 > stderr 1`] = `
114114
"☔️ error an identifier must only match a single package but "pkg-two" matches the following packages:
115115
☔️ error @manypkg/basic-fixture-pkg-two
116116
☔️ error @manypkg/basic-fixture-pkg-two-one
117117
"
118118
`;
119119

120-
exports[`Run command should execute "pkg-two start" and exit with 1: stdout 1`] = `""`;
120+
exports[`Run command > should execute "pkg-two start" and exit with 1 > stdout 1`] = `""`;
121121

122-
exports[`Run command should execute "pkg-two-one start" and exit with 0: stderr 1`] = `
122+
exports[`Run command > should execute "pkg-two-one start" and exit with 0 > stderr 1`] = `
123123
"warning package.json: No license field
124124
warning ../../package.json: No license field
125125
"
126126
`;
127127

128-
exports[`Run command should execute "pkg-two-one start" and exit with 0: stdout 1`] = `
128+
exports[`Run command > should execute "pkg-two-one start" and exit with 0 > stdout 1`] = `
129129
"$ echo hello start
130130
hello start
131131
"

packages/cli/src/checks/__tests__/EXTERNAL_MISMATCH.ts renamed to packages/cli/src/checks/__tests__/EXTERNAL_MISMATCH.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { expect, it } from "vitest";
12
import internalMismatch from "../EXTERNAL_MISMATCH.ts";
2-
import { getWS, getFakeWS, getRootWS } from "../../test-helpers.ts";
3+
import { getWS, getFakeWS, getRootWS } from "./test-helpers.ts";
34

45
let rootWorkspace = getRootWS();
56

packages/cli/src/checks/__tests__/INCORRECT_REPOSITORY_FIELD.ts renamed to packages/cli/src/checks/__tests__/INCORRECT_REPOSITORY_FIELD.test.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
getFakeString,
3-
getFakeWS,
4-
getRootWS,
5-
getWS,
6-
} from "../../test-helpers.ts";
1+
import { describe, expect, it } from "vitest";
2+
import { getFakeString, getFakeWS, getRootWS, getWS } from "./test-helpers.ts";
73
import check from "../INCORRECT_REPOSITORY_FIELD.ts";
84

95
describe("incorrect repository field", () => {

packages/cli/src/checks/__tests__/INTERNAL_MISMATCH.ts renamed to packages/cli/src/checks/__tests__/INTERNAL_MISMATCH.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
1+
import { describe, expect, it } from "vitest";
2+
import { getFakeWS, getRootWS, getWS } from "./test-helpers.ts";
23
import makeCheck, { ErrorType } from "../INTERNAL_MISMATCH.ts";
34

45
let rootWorkspace = getRootWS();

packages/cli/src/checks/__tests__/INVALID_DEV_AND_PEER_DEPENDENCY.ts renamed to packages/cli/src/checks/__tests__/INVALID_DEV_AND_PEER_DEPENDENCY.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
1+
import { describe, expect, it } from "vitest";
2+
import { getFakeWS, getRootWS, getWS } from "./test-helpers.ts";
23
import makeCheck from "../INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP.ts";
34

45
let rootWorkspace = getRootWS();

packages/cli/src/checks/__tests__/WORKSPACE_REQUIRED.ts renamed to packages/cli/src/checks/__tests__/WORKSPACE_REQUIRED.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
1+
import { expect, test } from "vitest";
2+
import { getFakeWS, getRootWS, getWS } from "./test-helpers.ts";
23
import makeCheck from "../WORKSPACE_REQUIRED.ts";
34
let rootWorkspace = getRootWS();
45

packages/cli/src/test-helpers.ts renamed to packages/cli/src/checks/__tests__/test-helpers.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// These are utils for testing.
2-
// I wanted to put this in the test folder but then jest tested it
3-
// Easier to put it here than add to jest ignore but maybe wrong.
4-
//
5-
// Who can say? ¯\_(ツ)_/¯
6-
71
import { Package } from "@manypkg/get-packages";
82
import crypto from "node:crypto";
93

packages/cli/src/run.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import fixturez from "fixturez";
23
import stripAnsi from "strip-ansi";
34
import { exec } from "tinyexec";

packages/find-root/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
},
1818
"devDependencies": {
1919
"@types/node": "^16.11.7",
20-
"fixturez": "^1.1.0"
20+
"fixturez": "^1.1.0",
21+
"vitest": "^3.1.2"
2122
},
2223
"engines": {
2324
"node": ">=14.18.0"

packages/find-root/src/index.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, test } from "vitest";
12
import fixturez from "fixturez";
23
import path from "node:path";
34
import { findRoot, findRootSync } from "./index.ts";

packages/get-packages/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"@manypkg/tools": "^1.1.1"
1818
},
1919
"devDependencies": {
20-
"fixturez": "^1.1.0"
20+
"fixturez": "^1.1.0",
21+
"vitest": "^3.1.2"
2122
},
2223
"engines": {
2324
"node": ">=14.18.0"

packages/get-packages/src/index.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import fixturez from "fixturez";
23
import path from "node:path";
34
import { getPackages, getPackagesSync } from "./index.ts";

0 commit comments

Comments
 (0)