0.0.6 • Published 2 years ago

same-story-jest-plugin v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

  1. Please install the package by running this command. npm i -D same-story-jest-plugin.
  2. Please install pipenv cli because this is based on Python cli (only for development). The cli will be distributed soon.
  3. 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.

  1. Please create a jest.setup.ts and copy the following code.
import { toBeSameStory } from 'same-story-jest-plugin/lib'

expect.extend({ toBeSameStory })
  1. Include jest.setup.ts to your jest.config.js file.
  module.exports = {
    roots: ["<rootDir>"],
    ...
    setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
  };
  1. If you are using typescript, include this to your tsconfig.json.
  ...
  "files": ["node_modules/same-story-jest-plugin/types/index.d.ts"]
  ...