0.1.19 • Published 4 years ago
@eigenspace/jest-screenshot-testing v0.1.19
Jest Screenshot Testing
Library adds an ability to test components using screenshot snapshots. It extends jest,
adding the toMatchComponentImageAsyncReact
method.
Features
Testing React-components (react elements, shallow and mount from enzyme).
Supporting another frameworks and simple css / html are in progress.
Installation
- Install all requirements to dev environment.
- Add the
@eigenspace/jest-screenshot-testing
as dependency. - Import the patcher (React example):
import { MatchImagePatcher } from '@eigenspace/jest-screenshot-testing';
- Define configuration according to PatcherArgs interface:
const options = { screenshoterUrl: environment.apiUrls.screenshoterUrl, globalStyles: TestGlobalStyles.globalStyle, themeWrapper: Init };
- Pass configuration to patcher
new MatchImagePatcher().do(options);
- Don't forget add:
'<rootDir>/config/jest/setup/expect.setup.tsx'
tosetupFiles
.
Environmental requirements
react
:16.x
,react-dom
:16.x
,jest
:24.x
,jest-styled-components
:>= 6.3.3
,styled-components
:4.x
Usage example
const props = { ...defaultProps, mode: ButtonModeType.PRIMARY };
await expect({ component, props }).toMatchComponentImageAsync();
Why do we have that dependencies?
enzyme
- api-helper for Jest testing. Added abilities to set state for components and get an instance (real class).enzyme-to-json
- a requirement for jest-screenshot-testing library.react-styleguidist
.react-test-renderer
- render React components to pure JavaScript objects.jest-image-snapshot
- library provides ability to check difference between two image@eigenspace/jest-testing-utils
- contains jest helpers and patchers.
Why do we have that dev dependencies?
@eigenspace/codestyle
- includes lint rules, config for typescript.@eigenspace/common-types
- contains common type definitions for our libraries.@eigenspace/eslint-config-codestyle
- package with eslint configurations.@eigenspace/helper-scripts
- common scripts for dev. environment.@types/*
- contains type definitions for specific library.husky
- used for configure git hooks.jest
- testing framework to write unit specs (including snapshots).lint-staged
- used for configure linters against staged git files.react
- used as utils for snapshot testing.react-dom
- used for render static markup.jest-styled-components
- a set of utilities for testing Styled Components with Jest.styled-components
- requirement of jest-styled-components.ts-jest
- it lets you use Jest to test projects written in TypeScript.eslint
- it checks code for readability, maintainability, and functionality errors.typescript
- is a superset of JavaScript that have static type-checking and ECMAScript features.whatwg-fetch
- this project is a polyfill forwindow.fetch
.
0.1.19
4 years ago
0.1.18
5 years ago
0.1.17
5 years ago
0.1.17-dev
6 years ago
0.1.16
6 years ago
0.1.15
6 years ago
0.1.14
6 years ago
0.1.13
6 years ago
0.1.12
6 years ago
0.1.11
6 years ago
0.1.10
6 years ago
0.1.9
6 years ago
0.1.8
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago