obsidian-community / jest-environment-obsidian Goto Github PK
View Code? Open in Web Editor NEWThis project forked from eth-p/jest-environment-obsidian
A Jest environment to facilitate unit testing for Obsidian plugins.
License: MIT License
This project forked from eth-p/jest-environment-obsidian
A Jest environment to facilitate unit testing for Obsidian plugins.
License: MIT License
0.0.1
After installing, when attempting to run a test via npm run test
, I received the following error:
● Validation Error:
Module jest-environment-obsidian should have "jest-preset.js" or "jest-preset.json" file at the root.
Configuration Documentation:
https://jestjs.io/docs/configuration
OS: Windows 10
Node: 18.16.1
Jest: 29.6.1
jest-environment-obsidian
via npm install --save-dev jest-environment-obsidian
preset
in jest.config.cjs
to 'jest-environment-obsidian'
npm run test
I was able to clear this error by copying node_modules/jest-environment-obsidian/dist/jest-preset.js
to node_modules/jest-environment-obsidian/
.
(TODO)
0.0.1
The issue appears to be due to the way that the path to node_modules/jest-message-util/build/index.js
is constructed in src/warning.ts
.
After successfully implementing workaround for #2, when attempting to run a test via npm run test
, I received the following error:
FAIL test/settings.test.ts
● Test suite failed to run
Cannot find module '../node_modules/jest-message-util/build/index.js'
Require stack:
- %project_root%\node_modules\jest-environment-obsidian\dist\jest-environment.js
- %project_root%\node_modules\jest-util\build\requireOrImportModule.js
- %project_root%\node_modules\jest-util\build\index.js
- %project_root%\node_modules\jest-config\build\getCacheDirectory.js
- %project_root%\node_modules\jest-config\build\Defaults.js
- %project_root%\node_modules\jest-config\build\normalize.js
- %project_root%\node_modules\jest-config\build\index.js
- %project_root%\node_modules\jest-cli\build\init\index.js
- %project_root%\node_modules\jest-cli\build\run.js
- %project_root%\node_modules\jest-cli\build\index.js
- %project_root%\node_modules\jest-cli\bin\jest.js
- %project_root%\node_modules\jest\bin\jest.js
at Object.<anonymous> (node_modules/jest-environment-obsidian/dist/jest-environment.js:132:32)
at Object.newLoader (node_modules/pirates/lib/index.js:121:7)
(path to project root truncated for readability)
OS: Windows 10
Node: 18.16.1
Jest: 29.6.1
jest-environment-obsidian
via npm install --save-dev jest-environment-obsidian
preset
in jest.config.cjs
to 'jest-environment-obsidian'
jest-preset.js
workaround from issue #2npm run test
I was able to clear this error by changing line 132 in dist/jest-environment.js
to the following:
var import_jest_message_util = require("../../../node_modules/jest-message-util/build/index.js");
This causes it to go up two more directory levels before attempting to traverse node_modules/
, which allows it to successfully find jest-message-util/build/index.js
.
The shims under src/runtime
could potentially be used with other testing frameworks (vitest, bun test, etc.).
I understand there is some Jest-specific logic in some of those files. But if those could be removed or replaced with some sort of dependency injection, then I think it could be really beneficial to extract these shims into their own package.
0.0.1
obsidian
This is blocking my test suite from running, even though the single test I have so far in my suite isn't touching PluginSettingTab
at all.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.