jest-if
v1.0.1
Published
Conditional tests for jest
Downloads
73
Readme
jest-if 🃏🤔
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('/');
});
},
);