Package Exports
- same-story-jest-plugin
- same-story-jest-plugin/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (same-story-jest-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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
pipenv
cli 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
toBeSameStory
matcher.
Setup for jest.
- Please create a
jest.setup.ts
and copy the following code.
import { toBeSameStory } from 'same-story-jest-plugin/lib'
expect.extend({ toBeSameStory })
- Include
jest.setup.ts
to yourjest.config.js
file.
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"]
...