Skip to content

Commit 603753e

Browse files
committed
tendermint-rpc: process?.env
1 parent fb414b8 commit 603753e

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

packages/tendermint-rpc/src/comet38/comet38client.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ describe("Comet38Client with CometBFT 0.38 backend", () => {
910910

911911
describe("With WebsocketClient", () => {
912912
// don't print out WebSocket errors if marked pending
913-
const onError = process.env.TENDERMINT_ENABLED ? console.error : () => 0;
913+
const onError =
914+
typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED ? console.error : () => 0;
914915
const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError);
915916
defaultTestSuite(factory, expected);
916917
websocketTestSuite(factory, expected);
@@ -946,7 +947,8 @@ describe("Comet38Client with CometBFT 1 backend", () => {
946947

947948
describe("With WebsocketClient", () => {
948949
// don't print out WebSocket errors if marked pending
949-
const onError = process.env.TENDERMINT_ENABLED ? console.error : () => 0;
950+
const onError =
951+
typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED ? console.error : () => 0;
950952
const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError);
951953
defaultTestSuite(factory, expected);
952954
websocketTestSuite(factory, expected);

packages/tendermint-rpc/src/rpcclients/http.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { defaultInstance, pendingWithoutTendermint } from "../testutil.spec";
33
import { http } from "./http";
44

55
function pendingWithoutHttpServer(): void {
6-
if (!process.env.HTTPSERVER_ENABLED) {
7-
pending("Set HTTPSERVER_ENABLED to enable HTTP tests");
6+
if (typeof process !== "undefined" && process?.env.HTTPSERVER_ENABLED) {
7+
return;
88
}
9+
pending("Set HTTPSERVER_ENABLED to enable HTTP tests");
910
}
1011

1112
const tendermintUrl = defaultInstance.url;

packages/tendermint-rpc/src/rpcclients/websocketclient.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { SubscriptionEvent } from "./rpcclient";
88
import { WebsocketClient } from "./websocketclient";
99

1010
function pendingWithoutTendermint(): void {
11-
if (!process.env.TENDERMINT_ENABLED) {
12-
pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests");
11+
if (typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED) {
12+
return;
1313
}
14+
pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests");
1415
}
1516

1617
describe("WebsocketClient", () => {

packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ describe("Tendermint34Client", () => {
898898

899899
describe("With WebsocketClient", () => {
900900
// don't print out WebSocket errors if marked pending
901-
const onError = process.env.TENDERMINT_ENABLED ? console.error : () => 0;
901+
const onError =
902+
typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED ? console.error : () => 0;
902903
const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError);
903904
defaultTestSuite(factory, expected);
904905
websocketTestSuite(factory, expected);

packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,8 @@ describe("Tendermint37Client", () => {
907907

908908
describe("With WebsocketClient", () => {
909909
// don't print out WebSocket errors if marked pending
910-
const onError = process.env.TENDERMINT_ENABLED ? console.error : () => 0;
910+
const onError =
911+
typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED ? console.error : () => 0;
911912
const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError);
912913
defaultTestSuite(factory, expected);
913914
websocketTestSuite(factory, expected);

packages/tendermint-rpc/src/testutil.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const tendermintInstances: Record<number, TendermintInstance> = {
100100
export const defaultInstance: TendermintInstance = tendermintInstances[34];
101101

102102
export function tendermintEnabled(): boolean {
103-
return !!process.env.TENDERMINT_ENABLED;
103+
return !!(typeof process !== "undefined" && process?.env.TENDERMINT_ENABLED);
104104
}
105105

106106
export function pendingWithoutTendermint(): void {

0 commit comments

Comments
 (0)