10000 Provide more context when test fails due to timeout in `waitsFor` by jasonrudolph · Pull Request #17351 · atom/atom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Provide more context when test fails due to timeout in waitsFor #17351

Merged
merged 1 commit into from
May 18, 2018

Conversation

jasonrudolph
Copy link
Contributor

Prior to this change, if a test timed out using waitsFor, you ended up with a fairly vague error message:

timeout: timed out after 5000 msec waiting for something to happen

If a test has multiple waitsFor calls, that error message leaves you wondering which one failed. 😭

We ran into this problem when investigating #17325, in which the failing test included multiple places where the timeout could have occurred:

beforeEach(() => {
  socketServer = net.createServer(() => {})
  socketPath = path.join(rootDir1, 'some.sock')
  waitsFor(done => socketServer.listen(socketPath, done))   // DID IT TIME OUT HERE?
})

afterEach(() => waitsFor(done => socketServer.close(done))) // OR HERE?  🤷🤷🤷🤷🤷

One option is to pass a custom error message to each waitsFor call. While that's still possible, we'd like the default error message to give you a better chance of diagnosing the problem. With the changes in this pull request, if you don't pass a custom error message, waitsFor will show you the filename and line number where the timeout occurred.

Example

Before

socket files on #darwin or #linux
it ignores them
timeout: timed out after 5000 msec waiting for something to happen

After

socket files on #darwin or #linux
it ignores them
timeout: timed out after 5000 msec waiting for condition at afterEach (~/github/fuzzy-finder/spec/fuzzy-finder-spec.js:263:27)

If no error message is given, show the filename and line number w
8000
hen a
test fails due to a timeout using waitsFor.

Co-authored-by: Max Brunsfeld <maxbrunsfeld@github.com>
@jasonrudolph jasonrudolph merged commit 83e7441 into master May 18, 2018
@jasonrudolph jasonrudolph deleted the improve-message-when-test-fails-due-to-timeout branch May 18, 2018 13:05
jasonrudolph added a commit that referenced this pull request May 18, 2018
…ue-to-timeout

Provide more context when test fails due to timeout in `waitsFor`
@bittin bittin mentioned this pull request Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0