Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ vi.mock('@perawallet/wallet-core-assets', () => ({

vi.mock('@perawallet/wallet-core-blockchain', () => ({
useNetwork: () => ({ network: 'mainnet' }),
// Analytics (packages/analytics/src/log.ts) reads useNetworkStore.getState().network on every
// trackEvent. Without it, each analytics call logs "No useNetworkStore export on the mock", and
// that pending console forwarding intermittently crashes the vitest worker at teardown
// (EnvironmentTeardownError, blamed on messages.test.tsx in the same worker).
useNetworkStore: Object.assign(() => 'mainnet', {
getState: () => ({ network: 'mainnet' }),
}),
}))

vi.mock('@hooks/useToast', () => ({
Expand Down
8 changes: 7 additions & 1 deletion apps/mobile/vitest.integration-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ import { useBottomSheetStore } from './src/modules/bottom-sheet'
// Reset it after each integration test so flows that count requests, or
// assert sheet visibility from a known clean slate, aren't poisoned by
// the previous case.
afterEach(() => {
afterEach(async () => {
useBottomSheetStore.getState().resetState()
// Drain the macrotask queue so any background async that settles just after a flow test
// finishes (a late query resolve / logger.warn from polling code — see the
// waitForConfirmation note below) forwards its console DURING the test window rather than at
// worker teardown, where a pending forward crashes as
// `EnvironmentTeardownError: Closing rpc while "onUserConsoleLog" was pending` and fails CI.
await new Promise(resolve => setTimeout(resolve, 0))
})

// jsdom installs its own `Uint8Array` constructor on `globalThis`. Node's
Expand Down
Loading