Skip to content

Commit

Permalink
maint: Maintain own test setup config.
Browse files Browse the repository at this point in the history
Don't extend from @patternslib/patternslib for setting up tests.
The config files are not included in the npm package distributions anymore.
  • Loading branch information
thet committed Dec 12, 2022
1 parent 626a267 commit 238ff3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("path");
const config = require("@patternslib/patternslib/jest.config.js");
const config = require("@patternslib/dev/jest.config.js");

config.setupFilesAfterEnv.push(path.resolve(__dirname, "./src/setup-tests.js"));

Expand Down
21 changes: 21 additions & 0 deletions src/setup-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Extra test setup.

import jquery from "jquery";
global.$ = global.jQuery = jquery;

jquery.expr.pseudos.visible = function () {
// Fix jQuery ":visible" selector always returns false in JSDOM.
// https://github.com/jsdom/jsdom/issues/1048#issuecomment-401599392
return true;
};

// Do not output error messages
import logging from "@patternslib/patternslib/core/logging";
logging.setLevel(50);
// level: FATAL

// patch dom.is_visible to not rely on jest-unavailable offsetWidth/Height
import dom from "@patternslib/patternslib/core/dom";
dom.is_visible = (el) => {
return !el.hidden && el.style.display !== "none";
};

0 comments on commit 238ff3b

Please sign in to comment.