Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
jest-os-detection
Advanced tools
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.
# with npm
npm install jest-os-detection
# with yarn
yarn add jest-os-detection
In your package.json
"jest": {
"setupFilesAfterEnv": ["jest-os-detection"],
}
describe.onWindows('this describe is only interpreted on Windows', () => {
it.onMac('this test is only interpreted on Mac', () => {})
test.onLinux('this test is only interpreted on Linux', () => {})
it.onMac.skip('this test is only interpreted on Mac but skipped', () => {})
test.onLinux.skip('this test is only interpreted on Linux but skipped', () => {})
it.onMac.only('only this test is executed on Mac', () => {})
test.onLinux.only('only this test is executed on Linux', () => {})
})
describe.onWindows.each([1, 2, 3])('several describe on windows', describeValue => {
it.onMac.each([1, 2, 3, 4])('several tests on windows', testValue => {})
test.onLinux.each([1, 2, 3, 4])('several tests on windows', testValue => {})
it.onMac.each.skip([1, 2, 3, 4])('several tests skipped on windows', testValue => {})
test.onLinux.each.skip([1, 2, 3, 4])('several tests skipped on windows', testValue => {})
it.onMac.each.only([1, 2, 3, 4])('only these tests will be executed on windows', testValue => {})
test.onLinux.each.only([1, 2, 3, 4])('only these tests will be executed on windows', testValue => {})
})
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()
To avoid type errors globally, you can add this to your tsconfig:
{
"files": [
"node_modules/jest-os-detection/index.d.ts"
]
}
FAQs
Allow to specify on which platform to run jest tests
The npm package jest-os-detection receives a total of 846 weekly downloads. As such, jest-os-detection popularity was classified as not popular.
We found that jest-os-detection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.