Skip to content

Commit 2762cef

Browse files
authored
test: move packages to workspace vitest (#3551)
1 parent e6e01e3 commit 2762cef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+282
-991
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib"
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"vitest.disableWorkspaceWarning": true
34
}

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"release:check": "changeset status --verbose --since=origin/main",
2727
"release:publish": "pnpm install && pnpm build && changeset publish",
2828
"release:version": "changeset version && pnpm install --lockfile-only && pnpm run changelog:generate",
29-
"test": "pnpm run --recursive test",
30-
"test:ci": "pnpm run --recursive test:ci",
29+
"test": "with-anvil turbo run test --concurrency=100%",
30+
"test:ci": "with-anvil turbo run test:ci --concurrency=100%",
3131
"type-bench": "pnpm --filter ./test/ts-benchmarks bench",
3232
"type-stats-repo": "attest stats packages/*",
3333
"vercel:prepare": "ln -sf /vercel/.foundry/bin/* node_modules/.bin/ && forge --version"
@@ -49,17 +49,19 @@
4949
"glob": "^10.4.2",
5050
"husky": ">=6",
5151
"lint-staged": "^15.2.10",
52+
"mock-game-contracts": "workspace:*",
5253
"prettier": "3.2.5",
5354
"prettier-plugin-solidity": "1.3.1",
54-
"prool": "^0.0.16",
55+
"prool": "^0.0.17",
5556
"shx": "^0.3.4",
5657
"sort-package-json": "^2.10.1",
5758
"tsup": "8.3.0",
5859
"tsx": "4.19.0",
5960
"turbo": "^1.9.3",
6061
"typescript": "5.4.2",
6162
"viem": "2.21.19",
62-
"vitest": "2.1.2"
63+
"vitest": "2.1.2",
64+
"with-anvil": "workspace:*"
6365
},
6466
"packageManager": "[email protected]",
6567
"engines": {

packages/abi-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build": "tsup",
3131
"clean": "shx rm -rf dist",
3232
"dev": "tsup --watch",
33-
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests",
33+
"test": "vitest --run",
3434
"test:ci": "pnpm run test"
3535
},
3636
"dependencies": {

packages/block-logs-stream/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"clean:js": "shx rm -rf dist",
3030
"dev": "tsup --watch",
3131
"lint": "eslint .",
32-
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests",
32+
"test": "vitest --run",
3333
"test:ci": "pnpm run test"
3434
},
3535
"dependencies": {
@@ -39,8 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"@types/debug": "^4.1.7",
42-
"viem": "2.21.19",
43-
"vitest": "3.0.4"
42+
"viem": "2.21.19"
4443
},
4544
"peerDependencies": {
4645
"viem": "2.x"

packages/cli/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"@types/toposort": "^2.0.6",
8484
"@types/yargs": "^17.0.10",
8585
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
86-
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
87-
"vitest": "0.34.6"
86+
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1"
8887
}
8988
}

packages/common/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"clean": "pnpm run clean:js",
6767
"clean:js": "shx rm -rf dist",
6868
"dev": "tsup --watch",
69-
"test": "vitest typecheck --run --passWithNoTests && vitest --run",
69+
"test": "vitest --run",
7070
"test:ci": "pnpm run test"
7171
},
7272
"dependencies": {
@@ -82,9 +82,7 @@
8282
},
8383
"devDependencies": {
8484
"@types/debug": "^4.1.7",
85-
"@viem/anvil": "^0.0.7",
86-
"viem": "2.21.19",
87-
"vitest": "0.34.6"
85+
"viem": "2.21.19"
8886
},
8987
"peerDependencies": {
9088
"@aws-sdk/client-kms": "3.x",

packages/common/src/account/kms/kmsKeyToAccount.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import { describe, it, expect, beforeAll } from "vitest";
1+
import { describe, it, expect, beforeAll, beforeEach } from "vitest";
22
import { KmsAccount, kmsKeyToAccount } from "./kmsKeyToAccount";
33
import { CreateKeyCommand, KMSClient } from "@aws-sdk/client-kms";
44
import { parseGwei, http, verifyMessage, verifyTypedData, createClient, parseEther } from "viem";
55
import { foundry } from "viem/chains";
6-
import { anvilRpcUrl, testClient } from "../../../test/common";
6+
import { getAnvilRpcUrl, createTestClient, snapshotAnvilState } from "with-anvil";
77
import { waitForTransaction } from "../../test/waitForTransaction";
8-
import { getTransactionReceipt, sendTransaction } from "viem/actions";
8+
import { getTransactionReceipt, sendTransaction, setBalance } from "viem/actions";
99

1010
describe.skipIf(!process.env.AWS_ENDPOINT_URL)("kmsKeyToAccount", () => {
1111
let account: KmsAccount;
1212
let keyId: string;
1313

14+
beforeAll(snapshotAnvilState);
15+
beforeEach(snapshotAnvilState);
16+
1417
beforeAll(async () => {
1518
const client = new KMSClient({
1619
region: "local",
@@ -32,7 +35,6 @@ describe.skipIf(!process.env.AWS_ENDPOINT_URL)("kmsKeyToAccount", () => {
3235
}
3336

3437
keyId = createResponse.KeyMetadata.KeyId;
35-
3638
account = await kmsKeyToAccount({ keyId, client });
3739
});
3840

@@ -108,11 +110,11 @@ describe.skipIf(!process.env.AWS_ENDPOINT_URL)("kmsKeyToAccount", () => {
108110

109111
it("can execute transactions", async () => {
110112
// Fund the KMS account
111-
testClient.setBalance({ address: account.address, value: parseEther("1") });
113+
setBalance(createTestClient(), { address: account.address, value: parseEther("1") });
112114

113115
const kmsClient = createClient({
114116
chain: foundry,
115-
transport: http(anvilRpcUrl),
117+
transport: http(getAnvilRpcUrl()),
116118
account,
117119
});
118120

packages/common/src/codegen/render-solidity/common.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("renderTableId", () => {
6262
it("returns Solidity code to compute table ID", () => {
6363
expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: false })).toMatchInlineSnapshot(`
6464
"
65-
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_TABLE });\`
65+
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: "somewhere", name: "Player", typeId: RESOURCE_TABLE });\`
6666
ResourceId constant _tableId = ResourceId.wrap(0x7462736f6d6577686572650000000000506c6179657200000000000000000000);
6767
"
6868
`);
@@ -71,7 +71,7 @@ describe("renderTableId", () => {
7171
it("returns Solidity code to compute offchain table ID", () => {
7272
expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: true })).toMatchInlineSnapshot(`
7373
"
74-
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_OFFCHAIN_TABLE });\`
74+
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: "somewhere", name: "Player", typeId: RESOURCE_OFFCHAIN_TABLE });\`
7575
ResourceId constant _tableId = ResourceId.wrap(0x6f74736f6d6577686572650000000000506c6179657200000000000000000000);
7676
"
7777
`);

packages/common/src/resourceToHex.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("resourceToHex", () => {
4545
name: "name",
4646
}),
4747
).toThrowErrorMatchingInlineSnapshot(
48-
'"Namespaces must fit into `bytes14`, but \\"AVeryLongNamespace\\" is too long."',
48+
`[Error: Namespaces must fit into \`bytes14\`, but "AVeryLongNamespace" is too long.]`,
4949
);
5050
});
5151

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { testClient } from "../../test/common";
1+
import { getTxpoolContent, mine } from "viem/actions";
2+
import { createTestClient } from "with-anvil";
23

34
export async function minePending(): Promise<void> {
4-
const content = await testClient.getTxpoolContent();
5+
const testClient = createTestClient();
6+
7+
const content = await getTxpoolContent(testClient);
58
if (!Object.keys(content.pending).length) return;
69

7-
await testClient.mine({ blocks: 1 });
10+
await mine(testClient, { blocks: 1 });
811
await minePending();
912
}

packages/common/src/test/waitForTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Hex } from "viem";
22
import { getTransactionReceipt } from "viem/actions";
3-
import { testClient } from "../../test/common";
43
import { minePending } from "./minePending";
4+
import { createTestClient } from "with-anvil";
55

66
export async function waitForTransaction(hash: Hex): Promise<void> {
77
await minePending();
8-
const receipt = await getTransactionReceipt(testClient, { hash });
8+
const receipt = await getTransactionReceipt(createTestClient(), { hash });
99
if (receipt.status === "reverted") {
1010
// TODO: better error
1111
throw new Error(`Transaction reverted (${hash})`);

packages/common/test/common.ts

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

packages/common/test/globalSetup.ts

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

packages/common/test/setup.ts

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

packages/common/vitest.config.ts

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

packages/create-mud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"copy-templates": "tsx ./scripts/copy-templates.ts",
2020
"dev": "tsup --watch",
2121
"prepublishOnly": "npm run clean && npm run build",
22-
"test": "pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs",
22+
"test": "shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs",
2323
"test:ci": "pnpm run test",
2424
"test:phaser": "bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project",
2525
"test:react": "bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project",

packages/dev-tools/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
"autoprefixer": "^10.4.14",
5656
"postcss": "^8.4.23",
5757
"tailwindcss": "^3.3.2",
58-
"viem": "2.21.19",
59-
"vitest": "0.34.6"
58+
"viem": "2.21.19"
6059
},
6160
"peerDependencies": {
6261
"@latticexyz/common": "2.x",

packages/entrykit/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"vite": "^5.4.1",
8383
"vite-plugin-dts": "^4.2.4",
8484
"vite-plugin-externalize-deps": "^0.8.0",
85-
"vitest": "0.34.6",
8685
"wagmi": "2.12.11"
8786
},
8887
"peerDependencies": {

packages/faucet/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
},
5151
"devDependencies": {
5252
"@types/debug": "^4.1.7",
53-
"viem": "2.21.19",
54-
"vitest": "0.34.6"
53+
"viem": "2.21.19"
5554
},
5655
"peerDependencies": {
5756
"viem": "2.x"

packages/gas-report/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"build": "tsup",
3333
"clean": "shx rm -rf dist",
3434
"dev": "tsup --watch",
35-
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test",
35+
"test": "vitest --run && forge test",
3636
"test:ci": "pnpm run test"
3737
},
3838
"dependencies": {
@@ -48,7 +48,6 @@
4848
"@types/stream-to-array": "^2.3.1",
4949
"@types/yargs": "^17.0.10",
5050
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
51-
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
52-
"vitest": "0.34.6"
51+
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1"
5352
}
5453
}

packages/protocol-parser/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"clean:js": "shx rm -rf dist",
3434
"dev": "tsup --watch",
3535
"lint": "eslint .",
36-
"test": "vitest typecheck --run && vitest --run",
36+
"test": "vitest --run",
3737
"test:ci": "pnpm run test"
3838
},
3939
"dependencies": {
@@ -43,8 +43,7 @@
4343
"abitype": "1.0.6"
4444
},
4545
"devDependencies": {
46-
"viem": "2.21.19",
47-
"vitest": "0.34.6"
46+
"viem": "2.21.19"
4847
},
4948
"peerDependencies": {
5049
"viem": "2.x"

packages/protocol-parser/src/hexToEncodedLengths.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("hexToEncodedLengths", () => {
2020

2121
it("throws if schema hex data is not bytes32", () => {
2222
expect(() => hexToEncodedLengths("0x01234")).toThrowErrorMatchingInlineSnapshot(
23-
'"Hex value \\"0x01234\\" has length of 5, but expected length of 64 for encoded lengths."',
23+
`[InvalidHexLengthForEncodedLengthsError: Hex value "0x01234" has length of 5, but expected length of 64 for encoded lengths.]`,
2424
);
2525
});
2626

@@ -29,7 +29,7 @@ describe("hexToEncodedLengths", () => {
2929
hexToEncodedLengths("0x0000000000000000000000000000400000000020000000002000000000000040"),
3030
).toThrowErrorMatchingInlineSnapshot(
3131
// eslint-disable-next-line max-len
32-
'"EncodedLengths \\"0x0000000000000000000000000000400000000020000000002000000000000040\\" total bytes length (64) did not match the summed length of all field byte lengths (128)."',
32+
`[EncodedLengthsLengthMismatchError: EncodedLengths "0x0000000000000000000000000000400000000020000000002000000000000040" total bytes length (64) did not match the summed length of all field byte lengths (128).]`,
3333
);
3434
});
3535
});

packages/react/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"eslint-plugin-react-hooks": "4.6.0",
4848
"jsdom": "^22.1.0",
4949
"react-test-renderer": "^18.2.0",
50-
"vite": "^4.3.6",
51-
"vitest": "0.34.6"
50+
"vite": "^4.3.6"
5251
}
5352
}

packages/schema-type/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"clean:js": "shx rm -rf dist/typescript",
4040
"dev": "tsup --watch",
4141
"gas-report": "gas-report --save gas-report.json",
42-
"test": "vitest typecheck --run && vitest --run && forge test",
42+
"test": "vitest --run && forge test",
4343
"test:ci": "pnpm run test"
4444
},
4545
"dependencies": {
@@ -49,8 +49,7 @@
4949
"@latticexyz/gas-report": "workspace:*",
5050
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
5151
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
52-
"viem": "2.21.19",
53-
"vitest": "0.34.6"
52+
"viem": "2.21.19"
5453
},
5554
"peerDependencies": {
5655
"viem": "2.x"

0 commit comments

Comments
 (0)