Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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
}
}
9 changes: 7 additions & 2 deletions cypress/.eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
}
22 changes: 6 additions & 16 deletions cypress/integration/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ 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', () => {
cy.findAllByLabelText(/^Label \d$/).should('have.length', 2)
})

it('findByPlaceholderText', () => {
cy.findByPlaceholderText('Input 1')
.click()
.type('Hello Placeholder')
cy.findByPlaceholderText('Input 1').click().type('Hello Placeholder')
})

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

it('findByText', () => {
cy.findByText('Button Text 1')
.click()
.should('contain', 'Button Clicked')
cy.findByText('Button Text 1').click().should('contain', 'Button Clicked')
})

it('findAllByText', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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)
})
Expand Down