same-story-jest-plugin
v0.0.6
Published
same story jest plugin
Maintainers
Readme
Same Story? Jest Plugin
What is this for?
This package is Jest plugin which runs in Jest context and let users to write a test to compare their work result against figma exported images. The way it works is similar to Figma plugin for same story but for Jest.
Prerequisite
- Please install the package by running this command.
npm i -D same-story-jest-plugin. - Please install
pipenvcli because this is based on Python cli (only for development). The cli will be distributed soon. - Please export png file from figma that you are going to compare with a correct name. That is the value for "dataPath" in your test input data for
toBeSameStorymatcher.
Setup for jest.
- Please create a
jest.setup.tsand copy the following code.
import { toBeSameStory } from 'same-story-jest-plugin/lib'
expect.extend({ toBeSameStory })- Include
jest.setup.tsto yourjest.config.jsfile.
module.exports = {
roots: ["<rootDir>"],
...
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
};- If you are using typescript, include this to your
tsconfig.json.
...
"files": ["node_modules/same-story-jest-plugin/types/index.d.ts"]
...