pwajet-test-utils
v1.5.1-alpha.6
Published
## What is it?
Downloads
43
Keywords
Readme
PWAjet test utils
What is it?
This library designed to help you write unit tests for your PWAjet extension.
pwajet is not available as a library or module: it available only in browser environment at runtime. So you should mock your imports from pwajet.core manually.
With this library you shouldn`t
Getting started
yarn add pwajet-test-utils -DAdd this to your jest setup file:
// Do it first to allow pwajet to init successfully
(global as any).pwajet = {
esmExtensions: []
}
// import utils
import pwajet from 'pwajet-test-utils'
// mock pwajet with utils
jest.mock(
'pwajet',
() => ({
core: pwajet.core,
}),
{ virtual: true }
)What is a setup file?
If your extension is based on pwajet-extension example, you need this file https://github.com/simtechdev/pwajet-extension/blob/master/src/setupTests.ts
else read the docs https://jestjs.io/docs/configuration#setupfiles-array
