Skip to content

Commit 3d1f67a

Browse files
committed
Fix tests (oh my)
1 parent 49ce8de commit 3d1f67a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/shared/test/components/Nav/nav.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { render, RenderResult, screen } from '@testing-library/react'
44
import Nav from '~/components/Nav'
55
import { useWalletAccount, useEns } from '~/shared/stores/wallet'
66

7+
/**
8+
* Jest, even when using the `jsdom` environment, does not respect the `browser` field
9+
* or `exports.*.browser` overrides in `package.json`. This means that Node-specific files
10+
* from `@streamr/*` are not automatically swapped for their browser-friendly alternatives.
11+
*
12+
* To ensure the correct files are used in tests, the following mapping is required.
13+
*/
14+
jest.mock('@streamr/dht/dist/src/connection/webrtc/NodeWebrtcConnection', () =>
15+
require('@streamr/dht/dist/src/connection/webrtc/BrowserWebrtcConnection'),
16+
)
17+
718
jest.mock('~/shared/stores/wallet', () => ({
819
__esModule: true,
920
useWalletAccount: jest.fn(),

0 commit comments

Comments
 (0)