Skip to content

Commit

Permalink
handle mocking es module
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed Jul 2, 2024
1 parent e5b15dc commit 233b8de
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libs/@guardian/identity-auth/src/__tests__/cookieRefresh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
import * as libs from '@guardian/libs';
import { cookieRefreshIfRequired } from '../cookieRefresh';

// jest is really not good with es modules :(
jest.mock(
'@guardian/libs',
() =>
({
__esModule: true,
...jest.requireActual('@guardian/libs'),
}) as typeof libs,
);

const mockedSetLocal = jest.spyOn(libs.storage.local, 'set');
const mockedGetLocal = jest.spyOn(libs.storage.local, 'get');
const mockedLocalIsAvailable = jest.spyOn(libs.storage.local, 'isAvailable');
Expand Down

0 comments on commit 233b8de

Please sign in to comment.