Skip to content

JsStore + Vite + Jest or Vitest #325

Answered by Korialstrazh
Korialstrazh asked this question in Q&A
Discussion options

You must be logged in to vote

OK, got a solution

If anyone faces this problem:

First install jest-worker, e.g. npm i -D jest-worker
Then add a jest setup file, e.g. jest.setup.ts with the following content:

/* eslint-disable import/no-extraneous-dependencies */
import 'fake-indexeddb/auto';
import 'jsdom-global/register';

// @ts-ignore
global.self = global;

and finally add to your jest configs:

...
setupFilesAfterEnv: [
    './jest.setup.ts',
  ],
...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Korialstrazh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant