Skip to content

Commit 54c5025

Browse files
committed
vitest: use import.meta.env so it's reachable in browser environment
1 parent ffb916e commit 54c5025

File tree

11 files changed

+13
-14
lines changed

11 files changed

+13
-14
lines changed

packages/cosmwasm-stargate/src/testutils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const deployedIbcReflect = {
144144
],
145145
};
146146

147-
export const wasmdEnabled: boolean = !!globalThis.process?.env.VITE_WASMD_ENABLED;
147+
export const wasmdEnabled: boolean = !!import.meta.env.VITE_WASMD_ENABLED;
148148

149149
/** Returns first element. Throws if array has a different length than 1. */
150150
export function fromOneElementArray<T>(elements: ArrayLike<T>): T {

packages/faucet-client/src/faucetclient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FaucetClient } from "./faucetclient";
22

3-
const enabled = !!globalThis.process?.env.VITE_FAUCET_ENABLED;
3+
const enabled = !!import.meta.env.VITE_FAUCET_ENABLED;
44

55
describe("FaucetClient", () => {
66
const faucetUrl = "http://localhost:8000";

packages/faucet/src/testutils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const simappEnabled = !!(
2-
globalThis.process?.env.VITE_SIMAPP47_ENABLED || globalThis.process?.env.VITE_SIMAPP50_ENABLED
2+
import.meta.env.VITE_SIMAPP47_ENABLED || import.meta.env.VITE_SIMAPP50_ENABLED
33
);

packages/socket/src/queueingstreamingsocket.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ConnectionStatus, QueueingStreamingSocket } from "./queueingstreamingsocket";
22

3-
const enabled = !!globalThis.process?.env.VITE_SOCKETSERVER_ENABLED;
3+
const enabled = !!import.meta.env.VITE_SOCKETSERVER_ENABLED;
44

55
describe("QueueingStreamingSocket", () => {
66
const socketServerUrl = "ws://localhost:4444/websocket";

packages/socket/src/reconnectingsocket.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Exec = (command: string, callback: (error: null | (Error & { readonly code?
55

66
const getExec = async (): Promise<Exec | undefined> => (await import("child_process")).exec;
77

8-
const enabled = !!globalThis.process?.env.VITE_SOCKETSERVER_ENABLED;
8+
const enabled = !!import.meta.env.VITE_SOCKETSERVER_ENABLED;
99

1010
describe("ReconnectingSocket", () => {
1111
const socketServerUrl = "ws://localhost:4444/websocket";

packages/socket/src/socketwrapper.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SocketWrapper } from "./socketwrapper";
22

3-
const enabled = !!globalThis.process?.env.VITE_SOCKETSERVER_ENABLED;
3+
const enabled = !!import.meta.env.VITE_SOCKETSERVER_ENABLED;
44

55
(enabled ? describe : describe.skip)("SocketWrapper", () => {
66
const socketServerUrlNonExisting = "ws://localhost:4443/websocket";

packages/socket/src/streamingsocket.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { toListPromise } from "@cosmjs/stream";
22

33
import { StreamingSocket } from "./streamingsocket";
44

5-
const enabled = !!globalThis.process?.env.VITE_SOCKETSERVER_ENABLED;
5+
const enabled = !!import.meta.env.VITE_SOCKETSERVER_ENABLED;
66

77
(enabled ? describe : describe.skip)("StreamingSocket", () => {
88
const socketServerUrl = "ws://localhost:4444/websocket";

packages/stargate/src/testutils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ import { AuthInfo, SignDoc, TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
1515
import { calculateFee, GasPrice } from "./fee";
1616
import { SigningStargateClientOptions } from "./signingstargateclient";
1717

18-
export const simapp47Enabled: boolean = !!globalThis.process?.env.VITE_SIMAPP47_ENABLED;
19-
export const simapp50Enabled: boolean = !!globalThis.process?.env.VITE_SIMAPP50_ENABLED;
18+
export const simapp47Enabled: boolean = !!import.meta.env.VITE_SIMAPP47_ENABLED;
19+
export const simapp50Enabled: boolean = !!import.meta.env.VITE_SIMAPP50_ENABLED;
2020
export const simappEnabled: boolean = simapp47Enabled || simapp50Enabled;
2121

2222
export const slowSimappEnabled: boolean =
23-
!!globalThis.process?.env.VITE_SLOW_SIMAPP47_ENABLED ||
24-
!!globalThis.process?.env.VITE_SLOW_SIMAPP50_ENABLED;
23+
!!import.meta.env.VITE_SLOW_SIMAPP47_ENABLED || !!import.meta.env.VITE_SLOW_SIMAPP50_ENABLED;
2524

2625
export function makeRandomAddressBytes(): Uint8Array {
2726
return Random.getBytes(20);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createJsonRpcRequest } from "../jsonrpc";
22
import { defaultInstance, tendermintEnabled } from "../testutils";
33
import { http } from "./http";
44

5-
const httpServerEnabled = !!globalThis.process?.env.VITE_HTTPSERVER_ENABLED;
5+
const httpServerEnabled = !!import.meta.env.VITE_HTTPSERVER_ENABLED;
66

77
const tendermintUrl = defaultInstance.url;
88
const echoUrl = "http://localhost:5555/echo_headers";

packages/tendermint-rpc/src/testutils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const tendermintInstances: Record<number, TendermintInstance> = {
9999

100100
export const defaultInstance: TendermintInstance = tendermintInstances[34];
101101

102-
export const tendermintEnabled: boolean = !!globalThis.process?.env.VITE_TENDERMINT_ENABLED;
102+
export const tendermintEnabled: boolean = !!import.meta.env.VITE_TENDERMINT_ENABLED;
103103

104104
export async function tendermintSearchIndexUpdated(): Promise<void> {
105105
// Tendermint needs some time before a committed transaction is found in search

0 commit comments

Comments
 (0)