Skip to content

Commit 2be9388

Browse files
committed
stargate: revert to jasmine
1 parent db10806 commit 2be9388

File tree

12 files changed

+62
-19
lines changed

12 files changed

+62
-19
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/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
"devDependencies": {
5252
"@cosmjs/crypto": "workspace:^",
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/stargate/src/fee.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ describe("GasPrice", () => {
6363
};
6464
for (const [input, expected] of Object.entries(inputs)) {
6565
const gasPrice = GasPrice.fromString(input);
66-
expect(gasPrice.amount.toString(), `Input: ${input}`).toEqual(expected.amount);
67-
expect(gasPrice.denom, `Input: ${input}`).toEqual(expected.denom);
66+
expect(gasPrice.amount.toString()).withContext(`Input: ${input}`).toEqual(expected.amount);
67+
expect(gasPrice.denom).withContext(`Input: ${input}`).toEqual(expected.denom);
6868
}
6969
});
7070

packages/stargate/src/modules/auth/queries.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("AuthExtension", () => {
5454
pendingWithoutSimapp();
5555
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrlHttp);
5656

57-
await expect(client.auth.account(nonExistentAddress)).rejects.toThrowError(
57+
await expectAsync(client.auth.account(nonExistentAddress)).toBeRejectedWithError(
5858
/account cosmos1p79apjaufyphcmsn4g07cynqf0wyjuezqu84hd not found/i,
5959
);
6060

packages/stargate/src/modules/bank/queries.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ describe("BankExtension", () => {
177177
pendingWithoutSimapp();
178178
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);
179179

180-
await expect(client.bank.denomMetadata("nothere")).rejects.toThrowError(/code = NotFound/i);
180+
await expectAsync(client.bank.denomMetadata("nothere")).toBeRejectedWithError(/code = NotFound/i);
181181

182182
cometClient.disconnect();
183183
});

packages/stargate/src/modules/ibc/queries.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ xdescribe("IbcExtension", () => {
9292
});
9393

9494
describe("consensusState", () => {
95-
it.skip("works", async () => {
95+
xit("works", async () => {
9696
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrlHttp);
9797

9898
const response = await client.ibc.channel.consensusState(
@@ -506,7 +506,7 @@ xdescribe("IbcExtension", () => {
506506
});
507507

508508
describe("consensusState", () => {
509-
it.skip("works", async () => {
509+
xit("works", async () => {
510510
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrlHttp);
511511

512512
// TODO: Find valid values

packages/stargate/src/modules/staking/queries.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ describe("StakingExtension", () => {
181181
pendingWithoutSimapp();
182182
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrlHttp);
183183

184-
await expect(
184+
await expectAsync(
185185
client.staking.redelegations(faucet.address0, validator.validatorAddress, validator.validatorAddress),
186-
).rejects.toThrowError(/redelegation not found/i);
186+
).toBeRejectedWithError(/redelegation not found/i);
187187

188188
cometClient.disconnect();
189189
});

packages/stargate/src/signingstargateclient.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,9 @@ describe("SigningStargateClient", () => {
985985
const height = await client.getHeight();
986986
const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
987987

988-
await expect(
988+
await expectAsync(
989989
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
990-
).rejects.toBeTruthyWith(
990+
).toBeRejectedWith(
991991
jasmine.objectContaining({
992992
code: 30,
993993
}),
@@ -1267,9 +1267,9 @@ describe("SigningStargateClient", () => {
12671267
const height = await client.getHeight();
12681268
const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
12691269

1270-
await expect(
1270+
await expectAsync(
12711271
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
1272-
).rejects.toBeTruthyWith(
1272+
).toBeRejectedWith(
12731273
jasmine.objectContaining({
12741274
code: 30,
12751275
}),

packages/stargate/src/stargateclient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ describe("StargateClient", () => {
188188
pendingWithoutSimapp();
189189
const client = await StargateClient.connect(simapp.tendermintUrlHttp);
190190

191-
await expect(client.getSequence(nonExistentAddress)).rejects.toThrowError(
191+
await expectAsync(client.getSequence(nonExistentAddress)).toBeRejectedWithError(
192192
/account '([a-z0-9]{10,90})' does not exist on chain/i,
193193
);
194194

@@ -558,7 +558,7 @@ describe("StargateClient", () => {
558558
});
559559
const txRawBytes2 = Uint8Array.from(TxRaw.encode(txRaw2).finish());
560560
const smallTimeoutMs = 1_000;
561-
await expect(client.broadcastTx(txRawBytes2, smallTimeoutMs)).rejects.toThrowError(
561+
await expectAsync(client.broadcastTx(txRawBytes2, smallTimeoutMs)).toBeRejectedWithError(
562562
TimeoutError,
563563
/transaction with id .+ was submitted but was not yet found on the chain/i,
564564
);

0 commit comments

Comments
 (0)