Skip to content

Commit dd81ca5

Browse files
authored
add options argument to cy.contains TS definition (#4756)
1 parent 456741b commit dd81ca5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cli/types/index.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,10 @@ declare namespace Cypress {
573573
* cy.contains(/^b\w+/)
574574
* // yields <ul>...</ul>
575575
* cy.contains('ul', 'apples')
576+
* // tries to find the given text for up to 1 second
577+
* cy.contains('my text to find', {timeout: 1000})
576578
*/
577-
contains(content: string | number | RegExp): Chainable<Subject>
579+
contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
578580
/**
579581
* Get the child DOM element that contains given text.
580582
*

cli/types/tests/cypress-tests.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ cy.wrap([{ foo: 'bar' }, { foo: 'baz' }])
191191
})
192192
})
193193

194-
cy.get('something').should('have.length', 1)
194+
cy.get('something').should('have.length', 1)
195195

196196
cy.stub().withArgs('').log(false).as('foo')
197197

@@ -297,3 +297,11 @@ namespace CypressTriggerTests {
297297

298298
const now = new Date(2019, 3, 2).getTime()
299299
cy.clock(now, ['Date'])
300+
301+
namespace CypressContainsTests {
302+
cy.contains('#app')
303+
cy.contains('my text to find')
304+
cy.contains('#app', 'my text to find')
305+
cy.contains('#app', 'my text to find', {log: false, timeout: 100})
306+
cy.contains('my text to find', {log: false, timeout: 100})
307+
}

0 commit comments

Comments
 (0)