Skip to content

Commit 97939da

Browse files
authored
chore: Fix ESLint config and failing test (#144)
1 parent 0df29e3 commit 97939da

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./node_modules/kcd-scripts/eslint.js",
3+
"rules": {
4+
"max-lines-per-function": "off",
5+
"testing-library/no-dom-import": "off" // We're not using React Testing Library here. We're wrapping DOM Testing Library directly
6+
}
7+
}

cypress/.eslintrc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"rules": {
3-
"max-lines-per-function": "off",
4-
"jest/valid-expect-in-promise": "off"
3+
"testing-library/await-async-query": "off", // Cypress chains don't use promises
4+
"testing-library/prefer-screen-queries": "off", // screen queries don't make sense in the context of Cypress Testing Library
5+
6+
// No Jest here
7+
"jest/valid-expect": "off",
8+
"jest/valid-expect-in-promise": "off",
9+
"jest/no-conditional-expect": "off"
510
}
611
}

cypress/integration/find.spec.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,23 @@ describe('find* dom-testing-library commands', () => {
77
// Test each of the types of queries: LabelText, PlaceholderText, Text, DisplayValue, AltText, Title, Role, TestId
88

99
it('findByLabelText', () => {
10-
cy.findByLabelText('Label 1')
11-
.click()
12-
.type('Hello Input Labelled By Id')
10+
cy.findByLabelText('Label 1').click().type('Hello Input Labelled By Id')
1311
})
1412

1513
it('findAllByLabelText', () => {
1614
cy.findAllByLabelText(/^Label \d$/).should('have.length', 2)
1715
})
1816

1917
it('findByPlaceholderText', () => {
20-
cy.findByPlaceholderText('Input 1')
21-
.click()
22-
.type('Hello Placeholder')
18+
cy.findByPlaceholderText('Input 1').click().type('Hello Placeholder')
2319
})
2420

2521
it('findAllByPlaceholderText', () => {
2622
cy.findAllByPlaceholderText(/^Input \d$/).should('have.length', 2)
2723
})
2824

2925
it('findByText', () => {
30-
cy.findByText('Button Text 1')
31-
.click()
32-
.should('contain', 'Button Clicked')
26+
cy.findByText('Button Text 1').click().should('contain', 'Button Clicked')
3327
})
3428

3529
it('findAllByText', () => {
@@ -107,12 +101,8 @@ describe('find* dom-testing-library commands', () => {
107101
})
108102

109103
it('findByText with a previous subject', () => {
110-
cy.get('#nested')
111-
.findByText('Button Text 1')
112-
.should('not.exist')
113-
cy.get('#nested')
114-
.findByText('Button Text 2')
115-
.should('exist')
104+
cy.get('#nested').findByText('Button Text 1').should('not.exist')
105+
cy.get('#nested').findByText('Button Text 2').should('exist')
116106
})
117107

118108
it('findByText within', () => {
@@ -180,7 +170,7 @@ describe('find* dom-testing-library commands', () => {
180170
})
181171

182172
it('findByText finding multiple items should error', () => {
183-
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\`)).`
173+
const errorMessage = `Found multiple elements with the text: /^Button Text/i`
184174
cy.on('fail', err => {
185175
expect(err.message).to.contain(errorMessage)
186176
})

0 commit comments

Comments
 (0)