Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions customJsdomEnvironment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const JSDOMEnvironment = require('jest-environment-jsdom').default;

module.exports = class CustomJsdomEnvironment extends JSDOMEnvironment {
async setup() {
await super.setup();
// Expose jsdom instance globally so tests can call jsdom.reconfigure()
this.global.jsdom = this.dom;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name this.dom is not guaranteed to be stable across jsdom versions. Consider adding error handling or version checking to ensure this property exists before exposing it globally.

Suggested change
this.global.jsdom = this.dom;
// Expose jsdom instance globally so tests can call jsdom.reconfigure()
if (this.dom) {
this.global.jsdom = this.dom;
}

}
};
Loading