{"id":23391300,"url":"https://github.com/kamiazya/jest-dynamic","last_synced_at":"2025-04-08T14:43:47.131Z","repository":{"id":37074518,"uuid":"233526078","full_name":"kamiazya/jest-dynamic","owner":"kamiazya","description":"An extension to dynamically switch the Jest test suite according to the environment (such as platform).","archived":false,"fork":false,"pushed_at":"2023-01-05T05:10:52.000Z","size":366,"stargazers_count":1,"open_issues_count":30,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T10:36:09.334Z","etag":null,"topics":["jest","nodejs","testing","testing-library","typescript-library"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@kamiazya/jest-dynamic","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamiazya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kamiazya","patreon":null,"open_collective":null,"ko_fi":"kamiazya","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-01-13T06:24:32.000Z","updated_at":"2022-01-24T19:38:13.000Z","dependencies_parsed_at":"2023-02-03T11:45:39.014Z","dependency_job_id":null,"html_url":"https://github.com/kamiazya/jest-dynamic","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamiazya%2Fjest-dynamic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamiazya%2Fjest-dynamic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamiazya%2Fjest-dynamic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamiazya%2Fjest-dynamic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamiazya","download_url":"https://codeload.github.com/kamiazya/jest-dynamic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247865840,"owners_count":21009235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest","nodejs","testing","testing-library","typescript-library"],"created_at":"2024-12-22T04:14:45.619Z","updated_at":"2025-04-08T14:43:47.110Z","avatar_url":"https://github.com/kamiazya.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kamiazya","https://ko-fi.com/kamiazya"],"categories":[],"sub_categories":[],"readme":"[![GitHub Action](https://github.com/kamiazya/ts-graphviz/workflows/NodeCI/badge.svg)](https://github.com/kamiazya/ts-graphviz/actions?workflow=NodeCI) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Test Coverage](https://api.codeclimate.com/v1/badges/0ec7daa6470b162e8775/test_coverage)](https://codeclimate.com/github/kamiazya/jest-dynamic/test_coverage) \u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg)](#contributors-)\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\n\n# @kamiazya/jest-dynamic\n\nAn extension to dynamically switch the [Jest](https://jestjs.io/) test suite according to the environment (such as platform).\n\n## Objectives\n\nWhen writing a platform-dependent test like [this issue](https://github.com/facebook/jest/issues/3652), it provides an option to flexibly change the test configuration.\n\n## Installation\n\nThis jest plugin can then be installed using [npm](https://www.npmjs.com/):\n\n[![NPM](https://nodei.co/npm/@kamiazya/jest-dynamic.png)](https://nodei.co/npm/@kamiazya/jest-dynamic/)\n\n```bash\n# yarn\nyarn add -D @kamiazya/jest-dynamic\n# or npm\nnpm install --save-dev @kamiazya/jest-dynamic\n```\n\n## API\n\n### Importing\n\n```typescript\nimport { onlyIf, onlyOn, skipIf, skipOn } from '@kamiazya/jest-dynamic';\n```\n\n### Skip\n\n### `skipOn(...platforms: NodeJS.Platform)`\n\nUsing `skipOn` will skip the test on the specified platform.\n\n**Example**\n\n```typescript\nskipOn('darwin')\n  .describe('Tests not run on Mac', () =\u003e {\n    it('is sample test', () =\u003e {\n      expect(true).toBe(true);\n    });\n  });\n```\n\n### `skipIf(condition: boolean | (() =\u003e boolean))`\n\nUsing `skipIf` will skip the test on condition.\n\n**Example**\n\n```typescript\nskipIf(process.env.NODE_ENV === 'CI')\n  .describe('This run on local test', () =\u003e {\n      expect(true).toBe(true);\n  });\n```\n\n### Only\n\n### `onlyOn(...platforms: NodeJS.Platform)`\n\nUse `onlyOn` to run one test of the block targeted for the specified platform.\n\n**Example**\n\n```typescript\nonlyOn('darwin', 'linux')\n  .describe('Run on Mac or Linux', () =\u003e {\n    test('sample', () =\u003e {\n      expect(true).toBe(true);\n    });\n  });\n\nonlyOn('win32')\n  .describe('Run on Windows', () =\u003e {\n    test('sample', () =\u003e {\n      expect(false).toBe(false);\n    });\n  });\n```\n\n### `onlyIf(condition: boolean | (() =\u003e boolean))`\n\nUse `onlyIf` to run one test of the block targeted on condition.\n\n**Example**\n\n```typescript\ndescribe('Tests', () =\u003e {\n  onlyIf(process.platform === 'win32')\n    .it('should be run on Windows', () =\u003e {\n      expect(false).toBe(false);\n    });\n\n  onlyIf(() =\u003e process.platform === 'linux')\n    .test('Run on Linux', () =\u003e {\n      expect(1).toBe(1);\n    });\n});\n```\n\n### Advanced Usage\n\n**Example**\n\nConditions can also be set on variables to increase reusability.\n\n```typescript\nconst onlyOnLinuxAndMac = onlyOn('linux', 'darwin');\nconst skipOnLinux = skipOn('linux');\nconst skipOnMac = skipOn('darwin');\n\nonlyOnLinuxAndMac\n  .describe('Tests', () =\u003e {\n    skipOnLinux\n      .test('sample', () =\u003e {\n        expect(false).toBe(false);\n      });\n\n    skipOnMac\n      .test('sample', () =\u003e {\n        expect(false).toBe(false);\n      });\n  });\n```\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://blog.kamiazya.tech/\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/35218186?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYuki Yamazaki\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kamiazya/jest-dynamic/commits?author=kamiazya\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#example-kamiazya\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"https://github.com/kamiazya/jest-dynamic/commits?author=kamiazya\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"https://github.com/kamiazya/jest-dynamic/commits?author=kamiazya\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors)\nspecification. Contributions of any kind welcome!\n\n## License\n\nThis software is released under the MIT License, see LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamiazya%2Fjest-dynamic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamiazya%2Fjest-dynamic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamiazya%2Fjest-dynamic/lists"}