Skip to content

Instantly share code, notes, and snippets.

@develohpanda
Last active November 18, 2020 09:38
Show Gist options
  • Save develohpanda/2cba96a9d34ea1314c943ad12c30e3f2 to your computer and use it in GitHub Desktop.
Save develohpanda/2cba96a9d34ea1314c943ad12c30e3f2 to your computer and use it in GitHub Desktop.
Conditionally run a unit test in jest
it.if = cb => cb() ? it : it.skip;
const isPackage = () => process.env.BUNDLE === 'package'
describe('suite', () => {
it.if(isPackage)('test', () => {
// test single
});
it.if(isPackage).each([1,2])('test each %s', num => {
// test each
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment