From bf6fe5c9bc57638dad9d6fd451654a69f99334c0 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sat, 31 Dec 2022 12:32:40 -0600 Subject: [PATCH] test: add eslint-plugin-jest --- .eslintrc.js | 1 + lib/__tests__/does-not-have-attribute.ts | 2 +- lib/__tests__/is-visible.ts | 15 --------------- package.json | 1 + pnpm-lock.yaml | 24 ++++++++++++++++++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5f8f5bee1..5f56c8f6b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,7 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:jest/recommended', 'plugin:prettier/recommended', ], env: { diff --git a/lib/__tests__/does-not-have-attribute.ts b/lib/__tests__/does-not-have-attribute.ts index 0df4985c4..150bedaeb 100644 --- a/lib/__tests__/does-not-have-attribute.ts +++ b/lib/__tests__/does-not-have-attribute.ts @@ -52,7 +52,7 @@ describe('assert.dom(...).doesNotHaveAttribute()', () => { ]); }); - test('fails for wrong content (string value)', () => { + test('fails for wrong content (boolean value)', () => { assert.dom('input').doesNotHaveAttribute('required'); assert.dom(document.querySelector('input')).doesNotHaveAttribute('required'); diff --git a/lib/__tests__/is-visible.ts b/lib/__tests__/is-visible.ts index 770e5091b..37ffc3c09 100644 --- a/lib/__tests__/is-visible.ts +++ b/lib/__tests__/is-visible.ts @@ -32,21 +32,6 @@ describe('assert.dom(...).isVisible()', () => { }, ]); }); - - test('fails if element is missing', () => { - document.body.innerHTML = '

foo

bar'; - - assert.dom('h2').isVisible(); - - expect(assert.results).toEqual([ - { - actual: 'Element h2 is not visible', - expected: 'Element h2 is visible', - message: 'Element h2 is visible', - result: false, - }, - ]); - }); }); describe('custom messages', () => { diff --git a/package.json b/package.json index 199903043..bc826c939 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "ember-try": "2.0.0", "eslint": "8.30.0", "eslint-config-prettier": "8.5.0", + "eslint-plugin-jest": "^27.1.7", "eslint-plugin-prettier": "4.2.1", "jest": "27.5.1", "lerna-changelog": "2.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be9213cce..f71f1d352 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,6 +31,7 @@ specifiers: ember-try: 2.0.0 eslint: 8.30.0 eslint-config-prettier: 8.5.0 + eslint-plugin-jest: ^27.1.7 eslint-plugin-prettier: 4.2.1 jest: 27.5.1 lerna-changelog: 2.2.0 @@ -78,6 +79,7 @@ devDependencies: ember-try: 2.0.0 eslint: 8.30.0 eslint-config-prettier: 8.5.0_eslint@8.30.0 + eslint-plugin-jest: 27.1.7_nm2ic5nngwviwdbcm2f7ah557u eslint-plugin-prettier: 4.2.1_kl4pe43v5b43npmso5hoplpbyi jest: 27.5.1 lerna-changelog: 2.2.0 @@ -7607,6 +7609,28 @@ packages: eslint: 8.30.0 dev: true + /eslint-plugin-jest/27.1.7_nm2ic5nngwviwdbcm2f7ah557u: + resolution: {integrity: sha512-0QVzf+og4YI1Qr3UoprkqqhezAZjFffdi62b0IurkCXMqPtRW84/UT4CKsYT80h/D82LA9avjO/80Ou1LdgbaQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^5.0.0 + eslint: ^7.0.0 || ^8.0.0 + jest: '*' + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + jest: + optional: true + dependencies: + '@typescript-eslint/eslint-plugin': 5.47.1_txmweb6yn7coi7nfrp22gpyqmy + '@typescript-eslint/utils': 5.47.1_lzzuuodtsqwxnvqeq4g4likcqa + eslint: 8.30.0 + jest: 27.5.1 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-prettier/4.2.1_kl4pe43v5b43npmso5hoplpbyi: resolution: {integrity: sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==} engines: {node: '>=12.0.0'}