From 455fec2972abb5b4a97de31118cd3bbf7ae8d92e Mon Sep 17 00:00:00 2001 From: Misha Moroshko Date: Sun, 10 May 2020 13:51:41 +1000 Subject: [PATCH] Add eslint-plugin-testing-library and eslint-plugin-jest-dom --- .eslintrc | 7 +++++-- package-lock.json | 24 ++++++++++++++++++++++++ package.json | 2 ++ src/components/Checkbox.test.js | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 925764e1..075e8a6a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,9 +3,12 @@ "extends": [ "eslint:recommended", "plugin:react/recommended", - "plugin:jest/recommended" + "plugin:jest/recommended", + "plugin:testing-library/recommended", + "plugin:testing-library/react", + "plugin:jest-dom/recommended" ], - "plugins": ["react-hooks", "jest"], + "plugins": ["react-hooks", "jest", "testing-library", "jest-dom"], "rules": { "no-unused-vars": [ "error", diff --git a/package-lock.json b/package-lock.json index c7645f4e..317d0106 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4923,6 +4923,15 @@ "@typescript-eslint/experimental-utils": "^2.5.0" } }, + "eslint-plugin-jest-dom": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest-dom/-/eslint-plugin-jest-dom-2.1.0.tgz", + "integrity": "sha512-J9H75qqPro0TA5AQcEJtZmxG4Go0KYjZYXAiAmvQsNUOIP1EzCF6BTJSkB/7Sw8wmzgLwNSvhMUDXqDfHa1HqA==", + "dev": true, + "requires": { + "requireindex": "~1.2.0" + } + }, "eslint-plugin-react": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.19.0.tgz", @@ -4966,6 +4975,15 @@ "integrity": "sha512-YKBY+kilK5wrwIdQnCF395Ya6nDro3EAMoe+2xFkmyklyhF16fH83TrQOo9zbZIDxBsXFgBbywta/0JKRNFDkw==", "dev": true }, + "eslint-plugin-testing-library": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-3.1.2.tgz", + "integrity": "sha512-Xuty2MvgA3vg0dutUwTSeUkOsWtg5Fj6v0c9K930bVfNwmgzF0yLRsZ/xD0OK6t+8UX9O5SZShpHYkk/gWovcA==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "^2.29.0" + } + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -10775,6 +10793,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true + }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", diff --git a/package.json b/package.json index 28289139..2938172e 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,10 @@ "cross-env": "7.0.2", "eslint": "7.0.0", "eslint-plugin-jest": "23.10.0", + "eslint-plugin-jest-dom": "^2.1.0", "eslint-plugin-react": "7.19.0", "eslint-plugin-react-hooks": "4.0.0", + "eslint-plugin-testing-library": "^3.1.2", "husky": "4.2.5", "jest": "26.0.1", "mq-polyfill": "1.1.8", diff --git a/src/components/Checkbox.test.js b/src/components/Checkbox.test.js index 472adb72..eb14037e 100644 --- a/src/components/Checkbox.test.js +++ b/src/components/Checkbox.test.js @@ -31,7 +31,7 @@ describe("Checkbox", () => { "id", checkboxContainer.getAttribute("aria-labelledby") ); - expect(checkboxContainer).toHaveAttribute("aria-checked", "false"); + expect(checkboxContainer).not.toBeChecked(); const checkboxInput = checkboxContainer.querySelector( 'input[type="checkbox"]'