Skip to content

Commit 2edd722

Browse files
committed
Merge branch 'web-test-runner'
2 parents 71e5a5b + 0c9e5b7 commit 2edd722

File tree

27 files changed

+6965
-9803
lines changed

27 files changed

+6965
-9803
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232
- run: npm install
33-
- run: make test-jest
33+
- run: make test-spec
3434
- run: make lint
3535
- run: make test-import-restrictions
3636
- run: make test-tsc

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/lgarron/Makefile-scripts
33

44
# Note: the first command becomes the default `make` target.
5-
NPM_COMMANDS = build build-esm build-bundle-global build-types build-bin build-sites build-site-twizzle build-site-experiments build-site-typedoc build-search-worker generate-js generate-js-parsers generate-js-svg dev link clean test test-dist-esm-node-import test-dist-esm-scramble-all-events test-dist-esm-parcel test-dist-esm-vite test-dist-esm-perf test-dist-esm-plain-esbuild-compat test-dist-experiments test-dist-not-imported-from-src test-import-restrictions test-jest test-tsc format setup initial-setup lint prepack postpublish
5+
NPM_COMMANDS = build build-esm build-bundle-global build-types build-bin build-sites build-site-twizzle build-site-experiments build-site-typedoc build-search-worker generate-js generate-js-parsers generate-js-svg dev link clean test test-dist-esm-node-import test-dist-esm-scramble-all-events test-dist-esm-parcel test-dist-esm-vite test-dist-esm-perf test-dist-esm-plain-esbuild-compat test-dist-experiments test-dist-not-imported-from-src test-import-restrictions test-spec test-tsc format setup initial-setup lint prepack postpublish
66

77
.PHONY: $(NPM_COMMANDS)
88
$(NPM_COMMANDS):

package-lock.json

Lines changed: 6605 additions & 9471 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,23 @@
6060
},
6161
"devDependencies": {
6262
"@babel/eslint-parser": "^7.18.9",
63-
"@babel/preset-env": "^7.18.9",
63+
"@babel/preset-env": "^7.18.10",
6464
"@babel/preset-typescript": "^7.18.6",
65+
"@esm-bundle/chai": "^4.3.4-fix.0",
66+
"@types/chai": "^4.3.3",
6567
"@types/dom-speech-recognition": "^0.0.1",
66-
"@types/jest": "^28.1.6",
6768
"@types/node": "^18.0.6",
6869
"@typescript-eslint/eslint-plugin": "^5.30.7",
6970
"@typescript-eslint/parser": "^5.30.7",
70-
"babel-jest": "^28.1.3",
71+
"@web/dev-server-esbuild": "^0.3.2",
72+
"@web/test-runner": "^0.14.0",
7173
"barely-a-dev-server": "^0.3.3",
74+
"chai": "^4.3.6",
7275
"esbuild": "^0.14.49",
7376
"eslint": "^8.20.0",
7477
"eslint-config-prettier": "^8.5.0",
7578
"eslint-plugin-html": "^7.0.0",
7679
"eslint-plugin-prettier": "^4.2.1",
77-
"jest": "^28.1.3",
78-
"jest-environment-jsdom": "^28.1.3",
7980
"jszip": "^3.10.0",
8081
"peggy": "^2.0.1",
8182
"prettier": "^2.7.1",
@@ -120,7 +121,7 @@
120121
"dev": "npm run initial-setup && node ./script/build/main.js sites dev",
121122
"link": "npm run build && npm link",
122123
"clean": "rm -rf dist .temp coverage src/cubing/search/search-worker-inside-generated* ./alg ./bluetooth ./kpuzzle ./notation ./protocol ./puzzle-geometry ./puzzles ./scramble ./search ./stream ./twisty",
123-
"test": "npm run test-jest && npm run lint && npm run test-import-restrictions && npm run test-tsc # keep test.yml & build.yml in sync with this",
124+
"test": "npm run test-spec && npm run lint && npm run test-import-restrictions && npm run test-tsc # keep test.yml & build.yml in sync with this",
124125
"test-dist-esm-node-import": "node script/test/dist/esm/node-import/main.mjs",
125126
"test-dist-esm-scramble-all-events": "node script/test/dist/esm/scramble-all-events/main.mjs",
126127
"test-dist-esm-parcel": "node ./script/test/dist/esm/parcel/main.js",
@@ -130,7 +131,7 @@
130131
"test-dist-experiments": "node ./script/test/dist/experiments/main.js",
131132
"test-dist-not-imported-from-src": "node ./script/test/dist/not-imported-from-src/main.js",
132133
"test-import-restrictions": "node ./script/test/import-restrictions/main.js",
133-
"test-jest": "npx jest --collectCoverage",
134+
"test-spec": "npx web-test-runner",
134135
"test-tsc": "npm run build-types && npx tsc --project ./tsconfig.json",
135136
"format": "npx eslint --fix --ext=js,ts src script; npx prettier --write src script",
136137
"setup": "npm install",
@@ -241,12 +242,5 @@
241242
],
242243
"@babel/preset-typescript"
243244
]
244-
},
245-
"jest": {
246-
"roots": [
247-
"<rootDir>/src",
248-
"<rootDir>/script"
249-
],
250-
"coverageDirectory": "<rootDir>/.temp/coverage"
251245
}
252246
}

src/cubing/alg/Alg.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { expect } from "../../test/chai-workaround";
12
import { Alg } from "./Alg";
2-
import "./test/alg-comparison";
33

44
describe("operation", () => {
55
it("can be constructed from a string", () => {
6-
expect(new Alg("R U R'").toString()).toEqual("R U R'");
6+
expect(new Alg("R U R'").toString()).to.equal("R U R'");
77
});
88
});

src/cubing/alg/alg-nodes/leaves/LineComment.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect } from "../../../../test/chai-workaround";
12
import { LineComment } from "./LineComment";
23

34
describe("LineComment", () => {
@@ -6,16 +7,16 @@ describe("LineComment", () => {
67
it("throws an error when a newline is provided in the input", () => {
78
expect(
89
() => new LineComment("This is a comment \n with a newline"),
9-
).toThrow(expectedErrorMessage);
10-
expect(() => new LineComment("A newline character \r")).toThrow(
10+
).to.throw(expectedErrorMessage);
11+
expect(() => new LineComment("A newline character \r")).to.throw(
1112
expectedErrorMessage,
1213
);
1314
});
1415

1516
it("does not throw an error when emojis are provided in the input", () => {
1617
expect(
1718
() => new LineComment("This string contains emojis 😀 😅"),
18-
).not.toThrow(expectedErrorMessage);
19+
).not.to.throw(expectedErrorMessage);
1920
});
2021

2122
it("does not throw an error when text characters are provided in the input", () => {
@@ -24,11 +25,11 @@ describe("LineComment", () => {
2425
new LineComment(
2526
"This is just a bunch of text characters in a comment.",
2627
),
27-
).not.toThrow(expectedErrorMessage);
28+
).not.to.throw(expectedErrorMessage);
2829
});
2930

3031
it("does not throw an error when special characters are provided in the input", () => {
31-
expect(() => new LineComment("Th!s cont@in$ $pec!@l ch@r$")).not.toThrow(
32+
expect(() => new LineComment("Th!s cont@in$ $pec!@l ch@r$")).not.to.throw(
3233
expectedErrorMessage,
3334
);
3435
});
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import { expect } from "../../../../test/chai-workaround";
2+
13
import { Move } from "./Move";
24

35
describe("Move", () => {
46
it("can be modified", () => {
5-
expect(new Move("R").modified({ amount: 2 }).toString()).toBe("R2");
7+
expect(new Move("R").modified({ amount: 2 }).toString()).to.equal("R2");
68
expect(
79
new Move("4r", 3)
810
.modified({
911
family: "u",
1012
outerLayer: 2,
1113
})
1214
.toString(),
13-
).toBe("2-4u3");
15+
).to.equal("2-4u3");
1416
});
1517
});

src/cubing/alg/operation.spec.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
1+
import { expect } from "../../test/chai-workaround";
2+
13
import { Alg } from "./Alg";
24
import { experimentalAppendMove } from "./operation";
35
import { Move } from "./alg-nodes";
4-
import "./test/alg-comparison";
56

67
describe("operation", () => {
78
it("can append moves", () => {
89
expect(
9-
experimentalAppendMove(new Alg("R U R'"), new Move("U2")),
10-
).toBeIdentical(new Alg("R U R' U2"));
10+
experimentalAppendMove(new Alg("R U R'"), new Move("U2")).isIdentical(
11+
new Alg("R U R' U2"),
12+
),
13+
).to.be.true;
1114
expect(
12-
experimentalAppendMove(new Alg("R U R'"), new Move("R", -2)),
13-
).toBeIdentical(new Alg("R U R' R2'"));
15+
experimentalAppendMove(new Alg("R U R'"), new Move("R", -2)).isIdentical(
16+
new Alg("R U R' R2'"),
17+
),
18+
).to.be.true;
1419
expect(
15-
experimentalAppendMove(new Alg("R U R'"), new Move("R")),
16-
).toBeIdentical(new Alg("R U R' R"));
20+
experimentalAppendMove(new Alg("R U R'"), new Move("R")).isIdentical(
21+
new Alg("R U R' R"),
22+
),
23+
).to.be.true;
1724
});
1825

1926
it("can coalesce appended moves", () => {
2027
expect(
2128
experimentalAppendMove(new Alg("R U R'"), new Move("U2"), {
2229
coalesce: true,
23-
}),
24-
).toBeIdentical(new Alg("R U R' U2"));
30+
}).isIdentical(new Alg("R U R' U2")),
31+
).to.be.true;
2532
expect(
2633
experimentalAppendMove(new Alg("R U R'"), new Move("R", -2), {
2734
coalesce: true,
28-
}),
29-
).toBeIdentical(new Alg("R U R3'"));
35+
}).isIdentical(new Alg("R U R3'")),
36+
).to.be.true;
3037
expect(
3138
experimentalAppendMove(new Alg("R U R'"), new Move("R"), {
3239
coalesce: true,
33-
}),
34-
).toBeIdentical(new Alg("R U"));
40+
}).isIdentical(new Alg("R U")),
41+
).to.be.true;
3542
});
3643

3744
it("can concat algs", () => {
38-
expect(new Alg("R U2").concat(new Alg("F' D"))).toBeIdentical(
39-
new Alg("R U2 F' D"),
40-
);
45+
expect(
46+
new Alg("R U2").concat(new Alg("F' D")).isIdentical(new Alg("R U2 F' D")),
47+
).to.be.true;
4148
expect(
4249
Array.from(new Alg("R U2").concat(new Alg("U R'")).childAlgNodes())
4350
.length,
44-
).toBe(4);
45-
expect(new Alg("R U2").concat(new Alg("U R'"))).toBeIdentical(
46-
new Alg("R U2 U R'"),
47-
);
51+
).to.equal(4);
52+
expect(
53+
new Alg("R U2").concat(new Alg("U R'")).isIdentical(new Alg("R U2 U R'")),
54+
).to.be.true;
4855
});
4956
});

src/cubing/alg/parseAlg.spec.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import { expect } from "../../test/chai-workaround";
2+
13
import { Alg } from "./Alg";
24
import { setAlgDebug } from "./debug";
35
import { parseAlg } from "./parseAlg";
4-
import "./test/alg-comparison";
56

67
describe("amount", () => {
78
it("handles 0 amounts", () => {
8-
expect(parseAlg("R0").toString()).toEqual("R0");
9+
expect(parseAlg("R0").toString()).to.equal("R0");
910
// We currently allow `R0'` because some programs might need to go out of their
1011
// way to avoid producing it in an edge cases. It's interpreted the same as
1112
// `R0`.
12-
expect(parseAlg("R0'").toString()).toEqual("R0");
13-
expect(() => parseAlg("R01")).toThrow(
13+
expect(parseAlg("R0'").toString()).to.equal("R0");
14+
expect(() => parseAlg("R01")).to.throw(
1415
"Error at char index 1: An amount can only start with 0 if it's exactly the digit 0.",
1516
);
16-
expect(() => parseAlg("R00")).toThrow(
17+
expect(() => parseAlg("R00")).to.throw(
1718
"Error at char index 1: An amount can only start with 0 if it's exactly the digit 0.",
1819
);
1920
});
@@ -25,34 +26,34 @@ describe("Clock", () => {
2526
parseAlg(
2627
" UR4+ DR4+ DL1+ UL3- U1+ R2- D5+ L6+ ALL4- y2 U3- R5- D4+ L6+ ALL5+ UL",
2728
).toString(),
28-
).toEqual(
29+
).to.equal(
2930
"UR4+ DR4+ DL1+ UL3- U1+ R2- D5+ L6+ ALL4- y2 U3- R5- D4+ L6+ ALL5+ UL",
3031
);
31-
expect(parseAlg("UR_PLUS_4 D_PLUS_3' U1+").toString()).toEqual(
32+
expect(parseAlg("UR_PLUS_4 D_PLUS_3' U1+").toString()).to.equal(
3233
"UR4+ D3- U1+",
3334
);
34-
expect(() => parseAlg("UR+").toString()).toThrow(
35+
expect(() => parseAlg("UR+").toString()).to.throw(
3536
"Clock dial moves must have an amount written as a natural number followed by + or -.",
3637
);
37-
expect(() => parseAlg("UR+2").toString()).toThrow(
38+
expect(() => parseAlg("UR+2").toString()).to.throw(
3839
"Clock dial moves must have an amount written as a natural number followed by + or -.",
3940
);
40-
expect(() => parseAlg("UR1+2").toString()).toThrow(
41+
expect(() => parseAlg("UR1+2").toString()).to.throw(
4142
"Unexpected character at index 4. Are you missing a space?",
4243
); // TODO: Better message
4344
});
4445
});
4546

4647
describe("Megaminx", () => {
4748
it("parses notation", () => {
48-
expect(parseAlg(" R++ D-- U' \n R++ D++ U").toString()).toEqual(
49+
expect(parseAlg(" R++ D-- U' \n R++ D++ U").toString()).to.equal(
4950
"R++ D-- U'\nR++ D++ U",
5051
);
51-
expect(parseAlg("R_PLUSPLUS_ D_PLUSPLUS_'").toString()).toEqual("R++ D--");
52-
expect(() => parseAlg("R1++").toString()).toThrow(
52+
expect(parseAlg("R_PLUSPLUS_ D_PLUSPLUS_'").toString()).to.equal("R++ D--");
53+
expect(() => parseAlg("R1++").toString()).to.throw(
5354
"Pochmann ++ or -- moves cannot have an amount written as a number.",
5455
);
55-
expect(() => parseAlg("R2++").toString()).toThrow(
56+
expect(() => parseAlg("R2++").toString()).to.throw(
5657
"Pochmann ++ or -- moves cannot have an amount other than 1.",
5758
);
5859
});
@@ -64,26 +65,27 @@ describe("Square-1", () => {
6465
parseAlg(
6566
"/ (-3,0) / (0, 3)/ (0,-3)/ (0,3) / (2,0) / (0,2)/ (-2,0) / (4,0) / (0,-2) / (0, 2) / (-1,4) / (0, -3) / (0, 3)",
6667
).toString(),
67-
).toEqual(
68+
).to.equal(
6869
"/ (-3, 0) / (0, 3) / (0, -3) / (0, 3) / (2, 0) / (0, 2) / (-2, 0) / (4, 0) / (0, -2) / (0, 2) / (-1, 4) / (0, -3) / (0, 3)",
6970
);
70-
expect(parseAlg("_SLASH_ (U_SQ_3' D_SQ_0) / (0, 3)").toString()).toEqual(
71+
expect(parseAlg("_SLASH_ (U_SQ_3' D_SQ_0) / (0, 3)").toString()).to.equal(
7172
"/ (-3, 0) / (0, 3)",
7273
);
73-
expect(() => parseAlg("(3, 4) /(1, 2)").toString()).toThrow(
74+
expect(() => parseAlg("(3, 4) /(1, 2)").toString()).to.throw(
7475
"Unexpected character at index 8. Are you missing a space?",
7576
);
7677
});
7778
});
7879

7980
describe("NISS", () => {
8081
it("does not allow carat NISS notation by default", () => {
81-
expect(() => parseAlg("R ^(U) D").toString()).toThrow(
82+
expect(() => parseAlg("R ^(U) D").toString()).to.throw(
8283
"Alg contained a carat but carat NISS notation is not enabled.",
8384
);
8485
});
8586
it("parses carat NISS notation", () => {
8687
setAlgDebug({ caratNISSNotationEnabled: true });
87-
expect(parseAlg("R ^(U L) D")).toBeIdentical(new Alg("R . D (U L)'"));
88+
expect(parseAlg("R ^(U L) D").isIdentical(new Alg("R . D (U L)'"))).to.be
89+
.true;
8890
});
8991
});

src/cubing/alg/test/alg-comparison.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)