Skip to content

Commit

Permalink
Mutation observer should not be used in test environment
Browse files Browse the repository at this point in the history
In older versions of JSOM jsdom/jsdom#639 mutation observer is not fully
supported and will throw on tests.

Wraps the usage of MutationObserver around the `process.env.NODE_ENV`
guard to protect for this scenario
  • Loading branch information
ling1726 committed Nov 10, 2021
1 parent e691cfa commit 5d974cb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,12 @@ export class DummyInputManager {
this.lastDummy = new DummyInput(win, { isFirst: false });
this._element = element;
this._addDummyInputs();
this._observeMutations(win);

// older versions of testing frameworks like JSDOM don't support MutationObserver
// https://github.com/jsdom/jsdom/issues/639
if (process.env.NODE_ENV !== 'test') {
this._observeMutations(win);
}
}

dispose(): void {
Expand Down

0 comments on commit 5d974cb

Please sign in to comment.