Skip to content

Commit e901991

Browse files
bruce-lindsaycharlierudolph
authored andcommitted
update step timeout error message for each interface (#1028)
1 parent 4a94dfd commit e901991

5 files changed

+20
-17
lines changed

features/before_after_all_hook_timeouts.feature

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Feature: before / after all hook timeouts
2828
When I run cucumber-js
2929
Then it fails
3030
And the error output contains the text snippets:
31-
| a handler errored, process exiting |
32-
| function timed out after 500 milliseconds |
33-
| features/support/handlers.js:5 |
31+
| a handler errored, process exiting |
32+
| function timed out, ensure the callback is executed within 500 milliseconds |
33+
| features/support/handlers.js:5 |
3434

3535
Examples:
3636
| TYPE |

features/hook_timeouts.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Feature: Step definition timeouts
3434
Then it fails
3535
And the output contains the text:
3636
"""
37-
function timed out after 500 milliseconds
37+
function timed out, ensure the callback is executed within 500 milliseconds
3838
"""
3939

4040

@@ -63,7 +63,7 @@ Feature: Step definition timeouts
6363
Then it fails
6464
And the output contains the text:
6565
"""
66-
function timed out after 500 milliseconds
66+
function timed out, ensure the callback is executed within 500 milliseconds
6767
"""
6868

6969

features/step_definition_timeouts.feature

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ Feature: Step definition timeouts
4444
Then it fails
4545
And the output contains the text:
4646
"""
47-
function timed out after 500 milliseconds
47+
function timed out, ensure the <TYPE> <ASSERT> within 500 milliseconds
4848
"""
4949

5050
Examples:
51-
| TYPE |
52-
| callback |
53-
| promise |
51+
| TYPE | ASSERT |
52+
| callback | is executed |
53+
| promise | resolves |
5454

5555

5656
Scenario Outline: slow steps can increase their timeout
@@ -81,13 +81,13 @@ Feature: Step definition timeouts
8181
Then it fails
8282
And the output contains the text:
8383
"""
84-
function timed out after 500 milliseconds
84+
function timed out, ensure the <TYPE> <ASSERT> within 500 milliseconds
8585
"""
8686

8787
Examples:
88-
| TYPE |
89-
| callback |
90-
| promise |
88+
| TYPE | ASSERT |
89+
| callback | is executed |
90+
| promise | resolves |
9191

9292

9393
Scenario Outline: steps can disable timeouts

src/user_code_runner.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export default class UserCodeRunner {
5454
if (timeoutInMilliseconds >= 0) {
5555
const timeoutPromise = new Promise((resolve, reject) => {
5656
timeoutId = Time.setTimeout(() => {
57-
const timeoutMessage = `function timed out after ${timeoutInMilliseconds} milliseconds`
57+
const timeoutMessage =
58+
'function timed out, ensure the ' +
59+
(callbackInterface ? 'callback is executed' : 'promise resolves') +
60+
` within ${timeoutInMilliseconds} milliseconds`
5861
reject(new Error(timeoutMessage))
5962
}, timeoutInMilliseconds)
6063
})

src/user_code_runner_spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('UserCodeRunner', () => {
131131
const { error, result } = await UserCodeRunner.run(this.options)
132132
expect(error).to.be.instanceof(Error)
133133
expect(error.message).to.eql(
134-
'function timed out after 100 milliseconds'
134+
'function timed out, ensure the callback is executed within 100 milliseconds'
135135
)
136136
expect(result).to.eql(undefined)
137137
})
@@ -204,7 +204,7 @@ describe('UserCodeRunner', () => {
204204
})
205205
})
206206

207-
describe('function times out', () => {
207+
describe('promise times out', function() {
208208
beforeEach(function() {
209209
this.options.fn = function() {
210210
return Promise.resolve('result').delay(200)
@@ -215,7 +215,7 @@ describe('UserCodeRunner', () => {
215215
const { error, result } = await UserCodeRunner.run(this.options)
216216
expect(error).to.be.instanceof(Error)
217217
expect(error.message).to.eql(
218-
'function timed out after 100 milliseconds'
218+
'function timed out, ensure the promise resolves within 100 milliseconds'
219219
)
220220
expect(result).to.eql(undefined)
221221
})

0 commit comments

Comments
 (0)