Skip to content

Jest Matchers to test generated templates

License

Notifications You must be signed in to change notification settings

grupoboticario/jest-scafflater

Repository files navigation

Jest Matchers to test generated templates.

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev @scafflater/jest-scafflater

or, for installation with yarn package manager.

yarn add --dev @scafflater/jest-scafflater

Usage

Import @scafflater/jest-scafflater once (for instance in your tests setup file) and you're good to go:

// In your own jest-setup.js (or any other name)
import "@scafflater/jest-scafflater";

// In jest.config.js add (if you haven't already)
setupFilesAfterEnv: ["<rootDir>/jest-setup.js"];

With TypeScript

If you're using TypeScript, make sure your setup file is a .ts and not a .js to include the necessary types.

You will also need to include your setup file in your tsconfig.json if you haven't already:

  // In tsconfig.json
  "include": [
    ...
    "./jest-setup.ts"
  ],

Custom matchers

toBeEqualDir

toBeEqualDir();

Compare two directory structures, including file contents.