Skip to content

Commit cfaf1ad

Browse files
authored
feat: Add timeout period to retry error message (#9123)
1 parent 3d1565e commit cfaf1ad

File tree

16 files changed

+58
-48
lines changed

16 files changed

+58
-48
lines changed

packages/desktop-gui/cypress/fixtures/runs.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"failedTests": [
2727
{
2828
"body": "function () {}",
29-
"error": "Timed out retrying: cy.click() failed because this element is being covered by another element:",
29+
"error": "Timed out retrying after 4000ms: cy.click() failed because this element is being covered by another element:",
3030
"id": "175e807c-ce85-5f94-938c-e2e30b090633",
3131
"instanceId": "d1609552-31b5-50c1-b307-c27c9553ccb8",
3232
"stack": "Error: Uncaught ReferenceError:\n at Object.$Cypress.Utils._.cypressErr (http://localhost:2020/__cypress/static/js/cypress.js:4678:15)\n at Object.$Cypress.Utils._.throwErr (http://localhost:2020/__cypress/static/js/cypress.js:4642:22)\n at Object.$Cypress.Utils._.throwErrByPath (http://localhost:2020/__cypress/static/js/cypress.js:4670:21)",
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"body": "function () {}",
56-
"error": "Timed out retrying: cy.click() failed because this element is being covered by another element:",
56+
"error": "Timed out retrying after 4000ms: cy.click() failed because this element is being covered by another element:",
5757
"failedFromHookId": "h1",
5858
"id": "ef0d934e-a247-5e60-b801-3c5be5aa8796",
5959
"instanceId": "d1609552-31b5-50c1-b307-c27c9553ccb8",

packages/driver/cypress/integration/commands/actions/trigger_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ describe('src/cy/commands/actions/trigger', () => {
10541054
it('throws when provided invalid event type', function (done) {
10551055
cy.on('fail', (err) => {
10561056
expect(this.logs.length).to.eq(2)
1057-
expect(err.message).to.eq('Timed out retrying: `cy.trigger()` `eventConstructor` option must be a valid event (e.g. \'MouseEvent\', \'KeyboardEvent\'). You passed: `FooEvent`')
1057+
expect(err.message).to.eq('Timed out retrying after 100ms: `cy.trigger()` `eventConstructor` option must be a valid event (e.g. \'MouseEvent\', \'KeyboardEvent\'). You passed: `FooEvent`')
10581058

10591059
done()
10601060
})

packages/driver/cypress/integration/commands/assertions_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ describe('src/cy/commands/assertions', () => {
490490

491491
it('throws when eventually times out', (done) => {
492492
cy.on('fail', (err) => {
493-
expect(err.message).to.eq('Timed out retrying: expected \'<button>\' to have class \'does-not-have-class\'')
493+
expect(err.message).to.eq('Timed out retrying after 50ms: expected \'<button>\' to have class \'does-not-have-class\'')
494494

495495
done()
496496
})

packages/driver/cypress/integration/commands/connectors_spec.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ describe('src/cy/commands/connectors', () => {
616616
}
617617

618618
cy.on('fail', (err) => {
619-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because the property: `foo` returned a `regexp` value instead of a function. `cy.invoke()` can only be used on properties that return callable functions.')
619+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because the property: `foo` returned a `regexp` value instead of a function. `cy.invoke()` can only be used on properties that return callable functions.')
620620
expect(err.message).to.include('`cy.invoke()` waited for the specified property `foo` to return a function, but it never did.')
621621
expect(err.message).to.include('If you want to assert on the property\'s value, then switch to use `cy.its()` and add an assertion such as:')
622622
expect(err.message).to.include('`cy.wrap({ foo: \'bar\' }).its(\'foo\').should(\'eq\', \'bar\')`')
@@ -636,7 +636,7 @@ describe('src/cy/commands/connectors', () => {
636636
}
637637

638638
cy.on('fail', (err) => {
639-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because the property: `bar` returned a `string` value instead of a function. `cy.invoke()` can only be used on properties that return callable functions.')
639+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because the property: `bar` returned a `string` value instead of a function. `cy.invoke()` can only be used on properties that return callable functions.')
640640
expect(err.message).to.include('`cy.invoke()` waited for the specified property `bar` to return a function, but it never did.')
641641
expect(err.message).to.include('If you want to assert on the property\'s value, then switch to use `cy.its()` and add an assertion such as:')
642642
expect(err.message).to.include('`cy.wrap({ foo: \'bar\' }).its(\'foo\').should(\'eq\', \'bar\')`')
@@ -972,7 +972,7 @@ describe('src/cy/commands/connectors', () => {
972972
cy.on('fail', (err) => {
973973
const { lastLog } = this
974974

975-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because the property: `foo` does not exist on your subject.')
975+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because the property: `foo` does not exist on your subject.')
976976
expect(err.message).to.include('`cy.invoke()` waited for the specified property `foo` to exist, but it never did.')
977977
expect(err.message).to.include('If you do not expect the property `foo` to exist, then add an assertion such as:')
978978
expect(err.message).to.include('`cy.wrap({ foo: \'bar\' }).its(\'quux\').should(\'not.exist\')`')
@@ -1019,9 +1019,9 @@ describe('src/cy/commands/connectors', () => {
10191019
cy.on('fail', (err) => {
10201020
const { lastLog } = this
10211021

1022-
expect(err.message).to.eq('Timed out retrying: expected \'foo\' to equal \'bar\'')
1022+
expect(err.message).to.eq('Timed out retrying after 100ms: expected \'foo\' to equal \'bar\'')
10231023

1024-
expect(lastLog.get('error').message).to.eq('Timed out retrying: expected \'foo\' to equal \'bar\'')
1024+
expect(lastLog.get('error').message).to.eq('Timed out retrying after 100ms: expected \'foo\' to equal \'bar\'')
10251025

10261026
done()
10271027
})
@@ -1033,7 +1033,7 @@ describe('src/cy/commands/connectors', () => {
10331033
cy.on('fail', (err) => {
10341034
const { lastLog } = this
10351035

1036-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because your subject is: `undefined`. You cannot invoke any functions such as `foo` on a `undefined` value.')
1036+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because your subject is: `undefined`. You cannot invoke any functions such as `foo` on a `undefined` value.')
10371037
expect(err.message).to.include('If you expect your subject to be `undefined`, then add an assertion such as:')
10381038
expect(err.message).to.include('`cy.wrap(undefined).should(\'be.undefined\')`')
10391039
expect(err.docsUrl).to.eq('https://on.cypress.io/invoke')
@@ -1049,7 +1049,7 @@ describe('src/cy/commands/connectors', () => {
10491049
cy.on('fail', (err) => {
10501050
const { lastLog } = this
10511051

1052-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because the property: `foo` is not a function, and instead returned a `undefined` value.')
1052+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because the property: `foo` is not a function, and instead returned a `undefined` value.')
10531053
expect(err.message).to.include('`cy.invoke()` waited for the specified property `foo` to become a callable function, but it never did.')
10541054
expect(err.message).to.include('If you expect the property `foo` to be `undefined`, then switch to use `cy.its()` and add an assertion such as:')
10551055
expect(err.message).to.include('`cy.wrap({ foo: undefined }).its(\'foo\').should(\'be.undefined\')`')
@@ -1066,7 +1066,7 @@ describe('src/cy/commands/connectors', () => {
10661066
cy.on('fail', (err) => {
10671067
const { lastLog } = this
10681068

1069-
expect(err.message).to.include('Timed out retrying: `cy.invoke()` errored because the property: `baz` does not exist on your subject.')
1069+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.invoke()` errored because the property: `baz` does not exist on your subject.')
10701070
expect(lastLog.get('error').message).to.include(err.message)
10711071
expect(err.docsUrl).to.eq('https://on.cypress.io/invoke')
10721072

@@ -1522,7 +1522,7 @@ describe('src/cy/commands/connectors', () => {
15221522
cy.on('fail', (err) => {
15231523
const { lastLog } = this
15241524

1525-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `foo` does not exist on your subject.')
1525+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `foo` does not exist on your subject.')
15261526
expect(err.message).to.include('`cy.its()` waited for the specified property `foo` to exist, but it never did.')
15271527
expect(err.message).to.include('If you do not expect the property `foo` to exist, then add an assertion such as:')
15281528
expect(err.message).to.include('`cy.wrap({ foo: \'bar\' }).its(\'quux\').should(\'not.exist\')`')
@@ -1539,7 +1539,7 @@ describe('src/cy/commands/connectors', () => {
15391539
cy.on('fail', (err) => {
15401540
const { lastLog } = this
15411541

1542-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `foo` returned a `undefined` value.')
1542+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `foo` returned a `undefined` value.')
15431543
expect(err.message).to.include('`cy.its()` waited for the specified property `foo` to become accessible, but it never did.')
15441544
expect(err.message).to.include('If you expect the property `foo` to be `undefined`, then add an assertion such as:')
15451545
expect(err.message).to.include('`cy.wrap({ foo: undefined }).its(\'foo\').should(\'be.undefined\')`')
@@ -1556,7 +1556,7 @@ describe('src/cy/commands/connectors', () => {
15561556
cy.on('fail', (err) => {
15571557
const { lastLog } = this
15581558

1559-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `foo` returned a `null` value.')
1559+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `foo` returned a `null` value.')
15601560
expect(err.message).to.include('`cy.its()` waited for the specified property `foo` to become accessible, but it never did.')
15611561
expect(err.message).to.include('If you expect the property `foo` to be `null`, then add an assertion such as:')
15621562
expect(err.message).to.include('`cy.wrap({ foo: null }).its(\'foo\').should(\'be.null\')`')
@@ -1573,7 +1573,7 @@ describe('src/cy/commands/connectors', () => {
15731573
cy.on('fail', (err) => {
15741574
const { lastLog } = this
15751575

1576-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `b` does not exist on your subject.')
1576+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `b` does not exist on your subject.')
15771577
expect(err.message).to.include('`cy.its()` waited for the specified property `b` to exist, but it never did.')
15781578
expect(err.message).to.include('If you do not expect the property `b` to exist, then add an assertion such as:')
15791579
expect(err.message).to.include('`cy.wrap({ foo: \'bar\' }).its(\'quux\').should(\'not.exist\')`')
@@ -1590,7 +1590,7 @@ describe('src/cy/commands/connectors', () => {
15901590
cy.on('fail', (err) => {
15911591
const { lastLog } = this
15921592

1593-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `a` returned a `undefined` value.')
1593+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `a` returned a `undefined` value.')
15941594
expect(err.message).to.include('`cy.its()` waited for the specified property `a` to become accessible, but it never did.')
15951595
expect(err.message).to.include('If you expect the property `a` to be `undefined`, then add an assertion such as:')
15961596
expect(err.message).to.include('`cy.wrap({ foo: undefined }).its(\'foo\').should(\'be.undefined\')`')
@@ -1628,7 +1628,7 @@ describe('src/cy/commands/connectors', () => {
16281628

16291629
it('can handle getter that throws', (done) => {
16301630
const spy = cy.spy((err) => {
1631-
expect(err.message).to.eq('Timed out retrying: some getter error')
1631+
expect(err.message).to.eq('Timed out retrying after 100ms: some getter error')
16321632

16331633
done()
16341634
}).as('onFail')
@@ -1650,7 +1650,7 @@ describe('src/cy/commands/connectors', () => {
16501650
cy.on('fail', (err) => {
16511651
const { lastLog } = this
16521652

1653-
expect(err.message).to.include('Timed out retrying: `cy.its()` errored because the property: `baz` does not exist on your subject.')
1653+
expect(err.message).to.include('Timed out retrying after 100ms: `cy.its()` errored because the property: `baz` does not exist on your subject.')
16541654
expect(err.docsUrl).to.eq('https://on.cypress.io/its')
16551655
expect(lastLog.get('error').message).to.include(err.message)
16561656
expect(lastLog.get('error').message).to.include(err.message)
@@ -1670,7 +1670,7 @@ describe('src/cy/commands/connectors', () => {
16701670
[null, undefined].forEach((val) => {
16711671
it(`throws on traversed '${val}' subject`, (done) => {
16721672
cy.on('fail', (err) => {
1673-
expect(err.message).to.include(`Timed out retrying: \`cy.its()\` errored because the property: \`a\` returned a \`${val}\` value. The property: \`b\` does not exist on a \`${val}\` value.`)
1673+
expect(err.message).to.include(`Timed out retrying after 100ms: \`cy.its()\` errored because the property: \`a\` returned a \`${val}\` value. The property: \`b\` does not exist on a \`${val}\` value.`)
16741674
expect(err.message).to.include('`cy.its()` waited for the specified property `b` to become accessible, but it never did.')
16751675
expect(err.message).to.include('If you do not expect the property `b` to exist, then add an assertion such as:')
16761676
expect(err.message).to.include(`\`cy.wrap({ foo: ${val} }).its('foo.baz').should('not.exist')\``)
@@ -1684,7 +1684,7 @@ describe('src/cy/commands/connectors', () => {
16841684

16851685
it(`throws on initial '${val}' subject`, (done) => {
16861686
cy.on('fail', (err) => {
1687-
expect(err.message).to.include(`Timed out retrying: \`cy.its()\` errored because your subject is: \`${val}\`. You cannot access any properties such as \`foo\` on a \`${val}\` value.`)
1687+
expect(err.message).to.include(`Timed out retrying after 100ms: \`cy.its()\` errored because your subject is: \`${val}\`. You cannot access any properties such as \`foo\` on a \`${val}\` value.`)
16881688
expect(err.message).to.include(`If you expect your subject to be \`${val}\`, then add an assertion such as:`)
16891689
expect(err.message).to.include(`\`cy.wrap(${val}).should('be.${val}')\``)
16901690
expect(err.docsUrl).to.eq('https://on.cypress.io/its')
@@ -1767,7 +1767,7 @@ describe('src/cy/commands/connectors', () => {
17671767
cy.on('fail', (err) => {
17681768
const { lastLog } = this
17691769

1770-
expect(err.message).to.include('Timed out retrying: expected \'bar\' to equal \'baz\'')
1770+
expect(err.message).to.include('Timed out retrying after 200ms: expected \'bar\' to equal \'baz\'')
17711771
expect(lastLog.get('error').message).to.include(err.message)
17721772

17731773
done()

packages/driver/cypress/integration/commands/files_spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('src/cy/commands/files', () => {
252252
expect(lastLog.get('state')).to.eq('failed')
253253

254254
expect(err.message).to.eq(stripIndent`
255-
Timed out retrying: \`cy.readFile(\"foo.json\")\` failed because the file does not exist at the following path:
255+
Timed out retrying after 50ms: \`cy.readFile(\"foo.json\")\` failed because the file does not exist at the following path:
256256
257257
\`/path/to/foo.json\``)
258258

@@ -274,7 +274,7 @@ describe('src/cy/commands/files', () => {
274274
expect(lastLog.get('error')).to.eq(err)
275275
expect(lastLog.get('state')).to.eq('failed')
276276
expect(err.message).to.eq(stripIndent`\
277-
Timed out retrying: \`cy.readFile(\"foo.json\")\` failed because the file exists when expected not to exist at the following path:
277+
Timed out retrying after 50ms: \`cy.readFile(\"foo.json\")\` failed because the file exists when expected not to exist at the following path:
278278
279279
\`/path/to/foo.json\``)
280280

@@ -297,7 +297,7 @@ describe('src/cy/commands/files', () => {
297297
expect(this.logs.length).to.eq(1)
298298
expect(lastLog.get('error')).to.eq(err)
299299
expect(lastLog.get('state')).to.eq('failed')
300-
expect(err.message).to.eq('Timed out retrying: expected \'foo\' to equal \'contents\'')
300+
expect(err.message).to.eq('Timed out retrying after 50ms: expected \'foo\' to equal \'contents\'')
301301

302302
done()
303303
})

packages/driver/cypress/integration/commands/querying_shadow_dom_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe('src/cy/commands/querying - shadow dom', () => {
191191

192192
it('has a custom error message if it cannot find a root', (done) => {
193193
cy.on('fail', (err) => {
194-
expect(err.message).to.equal(`Timed out retrying: Expected the subject to host a shadow root, but never found it.`)
194+
expect(err.message).to.equal(`Timed out retrying after 0ms: Expected the subject to host a shadow root, but never found it.`)
195195
expect(err.docsUrl).to.equal('https://on.cypress.io/shadow')
196196

197197
done()

packages/driver/src/cy/retries.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ const create = (Cypress, state, timeout, clearTimeout, whenStable, finishAsserti
6666

6767
({ error, onFail } = options)
6868

69-
const prependMsg = $errUtils.errByPath('miscellaneous.retry_timed_out').message
69+
const prependMsg = $errUtils.errByPath('miscellaneous.retry_timed_out', {
70+
ms: options._runnableTimeout,
71+
}).message
7072

7173
const retryErrProps = $errUtils.modifyErrMsg(error, prependMsg, (msg1, msg2) => {
7274
return `${msg2}${msg1}`

packages/driver/src/cypress/error_messages.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,9 @@ module.exports = {
820820
docsUrl: 'https://on.cypress.io/cannot-execute-commands-outside-test',
821821
},
822822
private_custom_command_interface: 'You cannot use the undocumented private command interface: `{{method}}`',
823-
retry_timed_out: 'Timed out retrying: ',
823+
retry_timed_out ({ ms }) {
824+
return `Timed out retrying after ${ms}ms: `
825+
},
824826
},
825827

826828
mocha: {

0 commit comments

Comments
 (0)