Skip to content

Commit 3f6b209

Browse files
committed
cosmwasm-stargate: revert to jasmine
1 parent 2be9388 commit 3f6b209

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",
@@ -51,12 +51,15 @@
5151
},
5252
"devDependencies": {
5353
"@istanbuljs/nyc-config-typescript": "^1.0.1",
54+
"@types/jasmine": "^4",
5455
"@types/karma-firefox-launcher": "^2",
5556
"@types/karma-jasmine": "^4",
5657
"@types/karma-jasmine-html-reporter": "^1",
5758
"@types/long": "^4.0.1",
5859
"@types/node": "*",
5960
"glob": "^11",
61+
"jasmine": "^4",
62+
"jasmine-spec-reporter": "^6",
6063
"karma": "^6.3.14",
6164
"karma-chrome-launcher": "^3.1.0",
6265
"karma-firefox-launcher": "^2.1.0",
@@ -69,7 +72,6 @@
6972
"source-map-support": "^0.5.19",
7073
"typedoc": "^0.28",
7174
"typescript": "~5.9",
72-
"vitest": "^3.2.4",
7375
"webpack": "^5.76.0",
7476
"webpack-cli": "^4.6.0"
7577
}

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,13 +283,16 @@ __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"
289290
"@types/long": "npm:^4.0.1"
290291
"@types/node": "npm:*"
291292
cosmjs-types: "npm:^0.10.1"
292293
glob: "npm:^11"
294+
jasmine: "npm:^4"
295+
jasmine-spec-reporter: "npm:^6"
293296
karma: "npm:^6.3.14"
294297
karma-chrome-launcher: "npm:^3.1.0"
295298
karma-firefox-launcher: "npm:^2.1.0"
@@ -302,7 +305,6 @@ __metadata:
302305
source-map-support: "npm:^0.5.19"
303306
typedoc: "npm:^0.28"
304307
typescript: "npm:~5.9"
305-
vitest: "npm:^3.2.4"
306308
webpack: "npm:^5.76.0"
307309
webpack-cli: "npm:^4.6.0"
308310
languageName: unknown

0 commit comments

Comments
 (0)