jest-if
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

jest-if 🃏🤔

npm build codecov

Conditional test blocks for jest

Installation

With npm:

npm install --save-dev jest-if

or yarn:

yarn add -D jest-if

Setup

Add jest-if to setupFilesAfterEnv in your configuration

module.exports = {
  setupFilesAfterEnv: ['jest-if'],
};

If using TypeScript, you can add the following to your tsconfig to include the necessary type definitions:

{
  "files": ["node_modules/jest-if/index.d.ts"]
}

Usage

Now you can conditionally write tests to be skipped unless the condition returns true:

describe.if(os.platform() !== 'windows')(
  'Unix specific tests can go here',
  () => {
    it('works as expected', () => {
      expect(path.resolve('/')).toEqual('/');
    });
  },
);

Readme

Keywords

Package Sidebar

Install

npm i jest-if

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

4.81 kB

Total Files

5

Last publish

Collaborators

  • tough-griff