@invisionag/jest-config-ivx
v6.2.2
Published
# Overview This Package contains complete configuration of jest for any InVision javascript repository, including: * enzyme support (including matchers) * styled-components support (including serializer and matchers) * stubs for browser functionality (lik
Downloads
114
Maintainers
Keywords
Readme
@invisionag/jest-config-ivx
Overview
This Package contains complete configuration of jest for any InVision javascript repository, including:
- enzyme support (including matchers)
- styled-components support (including serializer and matchers)
- stubs for browser functionality (like fetch)missing in jest testing enviroments
- stubs for asset files
Installation
Install @invisionag/jest-config-ivx
as a development dependency.
Usage
General
In your jest.config.js
:
module.exports = require('@invisionag/jest-config-ivx');
You can then extend the baseConfig as desired. A simple (complete) example to add an additional setup file would look like this:
const baseConfig = require('@invisionag/jest-config-ivx');
module.exports = {
...baseConfig,
setupFiles: [
...baseConfig.setupFiles,
'jest-localstorage-mock',
],
};
Enzyme
Enzyme is a renderer used to initialize react components in a testing enviroment (Documentation). Our jest configuration also ships with matchers to easily assert against enzyme objects (Documentation).
Styled Components
The configuration ships matchers to assert that styled-components elements include certain attributes Documentation
Fetch
We also include a minimalistic fetch mocking library to assert that requests were made by the tested code. See the Documentation for how to use it