Skip to content

Commit 25c4c54

Browse files
committed
cosmwasm-stargate: revert to jasmine
1 parent 847794b commit 25c4c54

File tree

8 files changed

+69
-24
lines changed

8 files changed

+69
-24
lines changed

.pnp.cjs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
if (process.env.SES_ENABLED) {
2+
require("ses");
3+
// eslint-disable-next-line no-undef
4+
lockdown();
5+
}
6+
7+
require("source-map-support").install();
8+
const defaultSpecReporterConfig = require("../../jasmine-spec-reporter.config.json");
9+
10+
// setup Jasmine
11+
const Jasmine = require("jasmine");
12+
const jasmine = new Jasmine();
13+
jasmine.loadConfig({
14+
spec_dir: "build",
15+
spec_files: ["**/*.spec.js"],
16+
helpers: [],
17+
random: false,
18+
seed: null,
19+
stopSpecOnExpectationFailure: false,
20+
});
21+
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15 * 1000;
22+
23+
// setup reporter
24+
const { SpecReporter } = require("jasmine-spec-reporter");
25+
const reporter = new SpecReporter({
26+
...defaultSpecReporterConfig,
27+
spec: {
28+
...defaultSpecReporterConfig.spec,
29+
displaySuccessful: !process.argv.includes("--quiet"),
30+
},
31+
});
32+
33+
// initialize and execute
34+
jasmine.env.clearReporters();
35+
jasmine.addReporter(reporter);
36+
void jasmine.execute();

packages/cosmwasm-stargate/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"format-text": "prettier --write \"./*.md\"",
3232
"build": "rm -rf ./build && tsc",
3333
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
34-
"test-node": "vitest run --globals",
34+
"test-node": "yarn node jasmine-testrunner.cjs",
3535
"test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox karma.conf.cjs",
3636
"test-chrome": "yarn pack-web && karma start --single-run --browsers ChromeHeadless karma.conf.cjs",
3737
"test": "yarn build-or-skip && yarn test-node",
@@ -52,13 +52,16 @@
5252
},
5353
"devDependencies": {
5454
"@istanbuljs/nyc-config-typescript": "^1.0.1",
55+
"@types/jasmine": "^4",
5556
"@types/karma-firefox-launcher": "^2",
5657
"@types/karma-jasmine": "^4",
5758
"@types/karma-jasmine-html-reporter": "^1",
5859
"@types/long": "^4.0.1",
5960
"@types/node": "*",
6061
"@types/pako": "^2.0.3",
6162
"glob": "^11",
63+
"jasmine": "^4",
64+
"jasmine-spec-reporter": "^6",
6265
"karma": "^6.3.14",
6366
"karma-chrome-launcher": "^3.1.0",
6467
"karma-firefox-launcher": "^2.1.0",
@@ -71,7 +74,6 @@
7174
"source-map-support": "^0.5.19",
7275
"typedoc": "^0.28",
7376
"typescript": "~5.9",
74-
"vitest": "^3.2.4",
7577
"webpack": "^5.76.0",
7678
"webpack-cli": "^4.6.0"
7779
}

packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe("CosmWasmClient", () => {
118118
pendingWithoutWasmd();
119119
const client = await CosmWasmClient.connect(wasmd.endpoint);
120120
const missing = makeRandomAddress();
121-
await expect(client.getSequence(missing)).rejects.toThrowError(
121+
await expectAsync(client.getSequence(missing)).toBeRejectedWithError(
122122
/account '([a-z0-9]{10,90})' does not exist on chain/i,
123123
);
124124
});
@@ -401,7 +401,7 @@ describe("CosmWasmClient", () => {
401401

402402
const nonExistentAddress = makeRandomAddress();
403403
const client = await CosmWasmClient.connect(wasmd.endpoint);
404-
await expect(client.queryContractRaw(nonExistentAddress, configKey)).rejects.toThrowError(
404+
await expectAsync(client.queryContractRaw(nonExistentAddress, configKey)).toBeRejectedWithError(
405405
/no such contract/i,
406406
);
407407
});
@@ -450,7 +450,7 @@ describe("CosmWasmClient", () => {
450450
assert(contract);
451451

452452
const client = await CosmWasmClient.connect(wasmd.endpoint);
453-
await expect(client.queryContractSmart(contract.address, { broken: {} })).rejects.toThrowError(
453+
await expectAsync(client.queryContractSmart(contract.address, { broken: {} })).toBeRejectedWithError(
454454
/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i,
455455
);
456456
});
@@ -460,9 +460,9 @@ describe("CosmWasmClient", () => {
460460

461461
const nonExistentAddress = makeRandomAddress();
462462
const client = await CosmWasmClient.connect(wasmd.endpoint);
463-
await expect(client.queryContractSmart(nonExistentAddress, { verifier: {} })).rejects.toThrowError(
464-
/no such contract/i,
465-
);
463+
await expectAsync(
464+
client.queryContractSmart(nonExistentAddress, { verifier: {} }),
465+
).toBeRejectedWithError(/no such contract/i);
466466
});
467467
});
468468
});

packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ describe("WasmExtension", () => {
234234
assert(hackatomCodeId);
235235
const client = await makeWasmClient(wasmd.endpoint);
236236
const nonExistentAddress = makeRandomAddress();
237-
await expect(client.wasm.getContractInfo(nonExistentAddress)).rejects.toThrowError(/no such contract/i);
237+
await expectAsync(client.wasm.getContractInfo(nonExistentAddress)).toBeRejectedWithError(
238+
/no such contract/i,
239+
);
238240
});
239241
});
240242

@@ -301,7 +303,7 @@ describe("WasmExtension", () => {
301303
pendingWithoutWasmd();
302304
const client = await makeWasmClient(wasmd.endpoint);
303305
const nonExistentAddress = makeRandomAddress();
304-
await expect(client.wasm.getAllContractState(nonExistentAddress)).rejects.toThrowError(
306+
await expectAsync(client.wasm.getAllContractState(nonExistentAddress)).toBeRejectedWithError(
305307
/no such contract/i,
306308
);
307309
});
@@ -331,9 +333,9 @@ describe("WasmExtension", () => {
331333
pendingWithoutWasmd();
332334
const client = await makeWasmClient(wasmd.endpoint);
333335
const nonExistentAddress = makeRandomAddress();
334-
await expect(client.wasm.queryContractRaw(nonExistentAddress, hackatomConfigKey)).rejects.toThrowError(
335-
/no such contract/i,
336-
);
336+
await expectAsync(
337+
client.wasm.queryContractRaw(nonExistentAddress, hackatomConfigKey),
338+
).toBeRejectedWithError(/no such contract/i);
337339
});
338340
});
339341

@@ -352,17 +354,17 @@ describe("WasmExtension", () => {
352354
assert(hackatomContractAddress);
353355
const client = await makeWasmClient(wasmd.endpoint);
354356
const request = { nosuchkey: {} };
355-
await expect(client.wasm.queryContractSmart(hackatomContractAddress, request)).rejects.toThrowError(
356-
/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i,
357-
);
357+
await expectAsync(
358+
client.wasm.queryContractSmart(hackatomContractAddress, request),
359+
).toBeRejectedWithError(/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i);
358360
});
359361

360362
it("throws for non-existent address", async () => {
361363
pendingWithoutWasmd();
362364
const client = await makeWasmClient(wasmd.endpoint);
363365
const nonExistentAddress = makeRandomAddress();
364366
const request = { verifier: {} };
365-
await expect(client.wasm.queryContractSmart(nonExistentAddress, request)).rejects.toThrowError(
367+
await expectAsync(client.wasm.queryContractSmart(nonExistentAddress, request)).toBeRejectedWithError(
366368
/no such contract/i,
367369
);
368370
});

packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,9 @@ describe("SigningCosmWasmClient", () => {
13711371
const height = await client.getHeight();
13721372
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
13731373

1374-
await expect(
1374+
await expectAsync(
13751375
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
1376-
).rejects.toBeTruthyWith(
1376+
).toBeRejectedWith(
13771377
jasmine.objectContaining({
13781378
code: 30,
13791379
}),
@@ -1653,9 +1653,9 @@ describe("SigningCosmWasmClient", () => {
16531653
const height = await client.getHeight();
16541654
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
16551655

1656-
await expect(
1656+
await expectAsync(
16571657
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
1658-
).rejects.toBeTruthyWith(
1658+
).toBeRejectedWith(
16591659
jasmine.objectContaining({
16601660
code: 30,
16611661
}),

packages/cosmwasm-stargate/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"baseUrl": ".",
55
"outDir": "build",
66
"experimentalDecorators": true,
7-
"rootDir": "src"
7+
"rootDir": "src",
8+
"types": ["jasmine", "karma-firefox-launcher", "karma-jasmine", "karma-jasmine-html-reporter", "node"]
89
},
910
"include": [
1011
"src/**/*"

yarn.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ __metadata:
283283
"@cosmjs/tendermint-rpc": "workspace:^"
284284
"@cosmjs/utils": "workspace:^"
285285
"@istanbuljs/nyc-config-typescript": "npm:^1.0.1"
286+
"@types/jasmine": "npm:^4"
286287
"@types/karma-firefox-launcher": "npm:^2"
287288
"@types/karma-jasmine": "npm:^4"
288289
"@types/karma-jasmine-html-reporter": "npm:^1"
@@ -291,6 +292,8 @@ __metadata:
291292
"@types/pako": "npm:^2.0.3"
292293
cosmjs-types: "npm:^0.10.1"
293294
glob: "npm:^11"
295+
jasmine: "npm:^4"
296+
jasmine-spec-reporter: "npm:^6"
294297
karma: "npm:^6.3.14"
295298
karma-chrome-launcher: "npm:^3.1.0"
296299
karma-firefox-launcher: "npm:^2.1.0"
@@ -304,7 +307,6 @@ __metadata:
304307
source-map-support: "npm:^0.5.19"
305308
typedoc: "npm:^0.28"
306309
typescript: "npm:~5.9"
307-
vitest: "npm:^3.2.4"
308310
webpack: "npm:^5.76.0"
309311
webpack-cli: "npm:^4.6.0"
310312
languageName: unknown

0 commit comments

Comments
 (0)