Skip to content

Commit

Permalink
Eslint plugin testing library (#871)
Browse files Browse the repository at this point in the history
* Use @testing-library/jest-dom, eslint-plugin-jest-dom and eslint-plugin-testing-library

* Update eslint-plugin-testing-library

* Change path for test plugins in eslint config
  • Loading branch information
mbraak authored Dec 21, 2024
1 parent 49fa833 commit 0f0f222
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import jestPlugin from "eslint-plugin-jest";
import jestDomPlugin from "eslint-plugin-jest-dom";
import perfectionistPlugin from "eslint-plugin-perfectionist";
import playwrightPlugin from "eslint-plugin-playwright";
import testingLibraryPlugin from "eslint-plugin-testing-library";

export default [
eslint.configs.recommended,
Expand Down Expand Up @@ -59,7 +60,11 @@ export default [
},
},
{
files: ["src/test/jqTree/**/*.ts"],
files: ["src/test/**/*.ts"],
...testingLibraryPlugin.configs["flat/dom"],
},
{
files: ["src/test/**/*.ts"],
...jestDomPlugin.configs["flat/recommended"],
},
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-perfectionist": "^4.4.0",
"eslint-plugin-playwright": "^2.1.0",
"eslint-plugin-testing-library": "^7",
"givens": "^1.3.9",
"graphql": "^16.10.0",
"jest": "^29.7.0",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/test/jqTree/loadOnDemand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ context("when a node has load_on_demand in the data", () => {
context("when the node is selected and doesn't have the focus", () => {
beforeEach(() => {
given.$tree.tree("selectNode", given.node);
(document.activeElement as HTMLElement).blur();
(document.activeElement as HTMLElement).blur(); // eslint-disable-line testing-library/no-node-access
});

it("keeps the node selected and not focused", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/jqTree/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ describe("refresh", () => {

it("rerenders the tree", () => {
const tree = given.$tree.tree("getTree");
(tree.children[0] as INode).name = "node1a";
(tree.children[0] as INode).name = "node1a"; // eslint-disable-line testing-library/no-node-access

expect(given.$tree).toHaveTreeStructure([
expect.objectContaining({ name: "node1" }),
Expand Down

0 comments on commit 0f0f222

Please sign in to comment.