Skip to content

vary error for callback vs promise #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion features/before_after_all_hook_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Feature: before / after all hook timeouts
Then it fails
And the error output contains the text snippets:
| a handler errored, process exiting |
| function timed out after 500 milliseconds |
| function timed out |
| 500 milliseconds |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this to: function timed out, ensure the callback is executed within 500 milliseconds?

| features/support/handlers.js:5 |

Examples:
Expand Down
4 changes: 2 additions & 2 deletions features/hook_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: Step definition timeouts
Then it fails
And the output contains the text:
"""
function timed out after 500 milliseconds
function timed out, ensure the callback is executed within 500 milliseconds
"""


Expand Down Expand Up @@ -63,7 +63,7 @@ Feature: Step definition timeouts
Then it fails
And the output contains the text:
"""
function timed out after 500 milliseconds
function timed out, ensure the callback is executed within 500 milliseconds
"""


Expand Down
10 changes: 5 additions & 5 deletions features/step_definition_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Feature: Step definition timeouts
Then it fails
And the output contains the text:
"""
function timed out after 500 milliseconds
function timed out, ensure the <TYPE> <ASSERT> within 500 milliseconds
"""

Examples:
| TYPE |
| callback |
| promise |
| TYPE | ASSERT |
| callback | is executed |
| promise | resolves |


Scenario Outline: slow steps can increase their timeout
Expand Down Expand Up @@ -81,7 +81,7 @@ Feature: Step definition timeouts
Then it fails
And the output contains the text:
"""
function timed out after 500 milliseconds
function timed out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do what was done earlier in this file?

"""

Examples:
Expand Down
5 changes: 4 additions & 1 deletion src/user_code_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export default class UserCodeRunner {
if (timeoutInMilliseconds >= 0) {
const timeoutPromise = new Promise((resolve, reject) => {
timeoutId = Time.setTimeout(() => {
const timeoutMessage = `function timed out after ${timeoutInMilliseconds} milliseconds`
const timeoutMessage =
'function timed out, ensure the ' +
(callbackInterface ? 'callback is executed' : 'promise resolves') +
` within ${timeoutInMilliseconds} milliseconds`
reject(new Error(timeoutMessage))
}, timeoutInMilliseconds)
})
Expand Down
6 changes: 3 additions & 3 deletions src/user_code_runner_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('UserCodeRunner', () => {
const { error, result } = await UserCodeRunner.run(this.options)
expect(error).to.be.instanceof(Error)
expect(error.message).to.eql(
'function timed out after 100 milliseconds'
'function timed out, ensure the callback is executed within 100 milliseconds'
)
expect(result).to.eql(undefined)
})
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('UserCodeRunner', () => {
})
})

describe('function times out', () => {
describe('promise times out', function() {
beforeEach(function() {
this.options.fn = function() {
return Promise.resolve('result').delay(200)
Expand All @@ -215,7 +215,7 @@ describe('UserCodeRunner', () => {
const { error, result } = await UserCodeRunner.run(this.options)
expect(error).to.be.instanceof(Error)
expect(error.message).to.eql(
'function timed out after 100 milliseconds'
'function timed out, ensure the promise resolves within 100 milliseconds'
)
expect(result).to.eql(undefined)
})
Expand Down