From 7b2f73ee87e3e31850aae551abfef0e77abb7a9b Mon Sep 17 00:00:00 2001 From: Nicholas Boll Date: Fri, 10 Jul 2020 09:39:47 -0600 Subject: [PATCH] fix: Fix ESLint config and failing test --- .eslintrc | 7 +++++++ cypress/.eslintrc | 9 +++++++-- cypress/integration/find.spec.js | 22 ++++++---------------- 3 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..66a0dbc --- /dev/null +++ b/.eslintrc @@ -0,0 +1,7 @@ +{ + "extends": "./node_modules/kcd-scripts/eslint.js", + "rules": { + "max-lines-per-function": "off", + "testing-library/no-dom-import": "off" // We're not using React Testing Library here. We're wrapping DOM Testing Library directly + } +} diff --git a/cypress/.eslintrc b/cypress/.eslintrc index 352fd0c..059897f 100644 --- a/cypress/.eslintrc +++ b/cypress/.eslintrc @@ -1,6 +1,11 @@ { "rules": { - "max-lines-per-function": "off", - "jest/valid-expect-in-promise": "off" + "testing-library/await-async-query": "off", // Cypress chains don't use promises + "testing-library/prefer-screen-queries": "off", // screen queries don't make sense in the context of Cypress Testing Library + + // No Jest here + "jest/valid-expect": "off", + "jest/valid-expect-in-promise": "off", + "jest/no-conditional-expect": "off" } } diff --git a/cypress/integration/find.spec.js b/cypress/integration/find.spec.js index d69443b..44a5577 100644 --- a/cypress/integration/find.spec.js +++ b/cypress/integration/find.spec.js @@ -7,9 +7,7 @@ describe('find* dom-testing-library commands', () => { // Test each of the types of queries: LabelText, PlaceholderText, Text, DisplayValue, AltText, Title, Role, TestId it('findByLabelText', () => { - cy.findByLabelText('Label 1') - .click() - .type('Hello Input Labelled By Id') + cy.findByLabelText('Label 1').click().type('Hello Input Labelled By Id') }) it('findAllByLabelText', () => { @@ -17,9 +15,7 @@ describe('find* dom-testing-library commands', () => { }) it('findByPlaceholderText', () => { - cy.findByPlaceholderText('Input 1') - .click() - .type('Hello Placeholder') + cy.findByPlaceholderText('Input 1').click().type('Hello Placeholder') }) it('findAllByPlaceholderText', () => { @@ -27,9 +23,7 @@ describe('find* dom-testing-library commands', () => { }) it('findByText', () => { - cy.findByText('Button Text 1') - .click() - .should('contain', 'Button Clicked') + cy.findByText('Button Text 1').click().should('contain', 'Button Clicked') }) it('findAllByText', () => { @@ -107,12 +101,8 @@ describe('find* dom-testing-library commands', () => { }) it('findByText with a previous subject', () => { - cy.get('#nested') - .findByText('Button Text 1') - .should('not.exist') - cy.get('#nested') - .findByText('Button Text 2') - .should('exist') + cy.get('#nested').findByText('Button Text 1').should('not.exist') + cy.get('#nested').findByText('Button Text 2').should('exist') }) it('findByText within', () => { @@ -180,7 +170,7 @@ describe('find* dom-testing-library commands', () => { }) it('findByText finding multiple items should error', () => { - const errorMessage = `Found multiple elements with the text: /^Button Text/i\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).` + const errorMessage = `Found multiple elements with the text: /^Button Text/i` cy.on('fail', err => { expect(err.message).to.contain(errorMessage) })