Jest OS detection
This module allows you to specify on which OS your tests should run. A common use case would be to have a CI running on different OS (say mac and windows) but you want to have all your tests in the same file. Unfortunately, some of your tests should only run on a specific platform due to OS specific features.
All tests that should not be run on the current platform will be automatically skipped.
Install
# with npm npm install jest-os-detection # with yarn yarn add jest-os-detection
Setup
In your package.json
"jest":
Usage
describe describeonWindows'several describe on windows' { itonMac'several tests on windows' {} testonLinux'several tests on windows' {} itonMaceach'several tests skipped on windows' {} testonLinuxeach'several tests skipped on windows' {} itonMaceach'only these tests will be executed on windows' {} testonLinuxeach'only these tests will be executed on windows' {}}
Supported features
Supported commands:
describe()
it()
test()
Supported platform:
<command>.onWindows()
<command>.onMac()
<command>.onLinux()
<command>.skipWindows()
<command>.skipMac()
<command>.skipLinux()
Supported sub-commands:
<command>.<platform>.each()
<command>.<platform>.only()
<command>.<platform>.skip()
<command>.<platform>.skip.each()
<command>.<platform>.only.each()
TypeScript
To avoid type errors globally, you can add this to your tsconfig: