pwajet-test-utils
TypeScript icon, indicating that this package has built-in type declarations

1.5.1-alpha.6 • Public • Published

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 -D

Add 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

Readme

Keywords

none

Package Sidebar

Install

npm i pwajet-test-utils

Weekly Downloads

2

Version

1.5.1-alpha.6

License

MIT

Unpacked Size

2.52 MB

Total Files

1140

Last publish

Collaborators

  • slipatnikov
  • simtechdevelopment
  • vzarayskiy
  • saunterer