{"id":17920898,"url":"https://github.com/eth-p/jest-environment-obsidian","last_synced_at":"2025-10-10T16:05:46.264Z","repository":{"id":152989202,"uuid":"622182494","full_name":"eth-p/jest-environment-obsidian","owner":"eth-p","description":"An experimental Jest environment for unit testing Obsidian plugins. (Old repo location)","archived":false,"fork":false,"pushed_at":"2023-04-15T23:08:04.000Z","size":447,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-28T20:34:54.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/obsidian-community/jest-environment-obsidian","language":"TypeScript","has_issues":false,"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/eth-p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-01T11:16:50.000Z","updated_at":"2024-10-18T15:12:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6faee6e-a3e1-44b5-b9d6-5e7b15f73abb","html_url":"https://github.com/eth-p/jest-environment-obsidian","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fjest-environment-obsidian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fjest-environment-obsidian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fjest-environment-obsidian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fjest-environment-obsidian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eth-p","download_url":"https://codeload.github.com/eth-p/jest-environment-obsidian/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229911002,"owners_count":18143228,"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":[],"created_at":"2024-10-28T20:29:33.669Z","updated_at":"2025-10-10T16:05:41.213Z","avatar_url":"https://github.com/eth-p.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-environment-obsidian\n\n![Obsidian Version Supported: v1.1.16](https://img.shields.io/badge/Obsidian-v1.1.16-blueviolet)\n[![NPM Downloads](https://img.shields.io/npm/dm/jest-environment-obsidian?label=Downloads)](https://www.npmjs.com/package/jest-environment-obsidian)\n[![MIT License](https://img.shields.io/github/license/obsidian-community/jest-environment-obsidian?label=License\u0026style=flat)](https://github.com/obsidian-community/jest-environment-obsidian/blob/main/LICENSE)\n[![Checks](https://github.com/obsidian-community/jest-environment-obsidian/actions/workflows/commit-checks.yml/badge.svg?event=push)](https://github.com/obsidian-community/jest-environment-obsidian/actions/workflows/commit-checks.yml)\n\nA [Jest](https://jestjs.io/) environment to facilitate unit testing for [Obsidian](https://obsidian.md/) plugins.\n\n\u003e **Notice:**  \n\u003e This project is a work-in-progress.\n\u003e\n\u003e Obsidian's API is fairly large, and it will take time to implement all of it in a test-friendly way. If some function doesn't work, please open an issue or pull request.\n\n## Installation\n\nThis package is available on the `npm` registry. You can install it using `npm` or `yarn`.\n\n```bash\nnpm install --save-dev jest-environment-obsidian\n```\n\n### Requirements\n\nThese are the minimum requirements that we test for. You may have luck with earlier versions of the required software, but we won't be able to provide support for it.\n\n-   `NodeJS` \u003e= 15.0.0\n-   `Jest` \u003e= 29.0.0\n\n## Usage\n\nThere are two ways to use `jest-environment-obsidian` in your project: for all unit tests, or for specific unit test files. If you're not sure about what you want to do, you can see [our examples](./examples/) for inspiration.\n\n### For All Tests\n\nIf you want to use `jest-environment-obsidian` for all your unit tests, you can use `jest-environment-obsidian` as a preset. This will add the required setup files and module resolver.\n\n```js\nmodule.exports = {\n\t// ...\n\tpreset: 'jest-environment-obsidian',\n};\n```\n\nIf you want to provide your own configuration on top of `jest-environment-obsidian`'s preset, we recommend using the `extend` function provided in our preset:\n\n```js\nconst { extend } = require('jest-environment-obsidian/jest-preset');\nmodule.exports = extend({\n\tsetupFiles: ['...'],\n});\n```\n\n### For Individual Tests\n\nIf you only want to test a specific files under the `jest-environment-obsidian` environment, you can add a multi-line pragma comment at the top your unit test file:\n\n```js\n/**\n * @jest-environment jest-environment-obsidian\n */\n```\n\n## Features\n\n### Obsidian's Prototype Extensions\n\nObsidian adds custom functions and properties to existing DOM and ECMAScript types. These have been reimplemented under `jest-environment-obsidian` and are available within unit tests.\n\n### Obsidian Module\n\nThe Obsidian module is automatically shimmed for you. While it's still good practice to isolate code, as long as you use `jest-environment-obsidian`, having `import {...} from \"obsidian\"` in source files no longer prevents unit tests from running.\n\n### Warnings\n\nAs a way to help with test-driven-development and identify why certain unit tests may be failing, `jest-environment-obsidian` creates and prints warning messages after running tests.\n\nIndividual warnings can be disabled by adding a `@obsidian-jest-ignore node-must-be-within-document \u003cwarningName\u003e` pragma comment in a file. Multiple comments can be added to disable different warnings.\n\n## Configuration\n\nThe test environment can be configured globally with the `testEnvironmentOptions` option inside your Jest config, or on a per-file basis using one of the supported doc block pragmas.\n\n### `conformance`\n\nConfigures how strictly the test environment tries to conform to Obsidian's implementation of its API.\n\nWhen set to `strict`, certain functions and behaviours will work as though they were running within the real Obsidian environment. As a consequence, more boilerplate code will be needed for certain unit tests to pass.\n\n**Pragma:** `@obsidian-conformance`  \n**Options:** `\"lax\"`, `\"strict\"`  \n**Default:** `\"lax\"`\n\n### `version`\n\nConfigures the reported `apiVersion` inside the `obsidian` module.\n\n**Pragma:** `@obsidian-version`  \n**Options:** `string`  \n**Default:** `1.1.16`\n\n### `ignoreWarnings`\n\nDisables printing of specific [warning messages](#warnings).\n\n**Pragma:** `@obsidian-jest-ignore`  \n**Options:** A string array of warning IDs, or a single string ID if within a pragma comment.  \n**Default:** `[]`\n\n### `missingExports`\n\nChanges how `jest-environment-obsidian` handles missing exports from shimmed modules.\nBy default, a warning will be emitted to let you know that your tests may behave unexpectedly.\n\n**Options:** `\"warning\", \"error\", \"undef\"`  \n**Default:** `\"warning\"`\n\n\n## Contributing\n\nWant to help out? Check out the [contributing guide](./CONTRIBUTING.md)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fjest-environment-obsidian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feth-p%2Fjest-environment-obsidian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fjest-environment-obsidian/lists"}