Skip to content
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

No error for unending test when running in browser #201

Open
whastings opened this issue Oct 19, 2015 · 13 comments
Open

No error for unending test when running in browser #201

whastings opened this issue Oct 19, 2015 · 13 comments

Comments

@whastings
Copy link

I'm using Tape to test a practice Promise implementation.

When I run my tests in the browser, I notice that Tape does not throw an exception for an unending test like it does when run through Node. Note that I'm using Webpack to bundle Tape, my tests, and my implementation code.

It looks like Tape relies on process.on('exit') to detect unending tests. Since this isn't available in the browser, does anyone know what I can to do get an exception thrown when a test doesn't end?

@ljharb
Copy link
Collaborator

ljharb commented Oct 19, 2015

Which test doesn't end?

@Raynos
Copy link
Collaborator

Raynos commented Oct 19, 2015

@whasting timeouts.

@Raynos
Copy link
Collaborator

Raynos commented Oct 19, 2015

We could add a default 30s timeout to each block

@whastings
Copy link
Author

@ljharb all the tests are fine right now. But if I modify one of them so it won't end, I don't get any error.

@Raynos It would be great if I could set a default timeout value for all my tests.

@AsaAyers
Copy link

How does tape determine that it's done when running in the browser? I have a never ending test and tape claims it's done:

1..1
# tests 1
# pass  1

# ok

@AsaAyers
Copy link

Timeouts don't appear to work in the browser:

test('never ending test', assert => {
    assert.timeoutAfter(10000)
})

test('next test', assert => {
    assert.end()
})

produces this output:

TAP version 13
# never ending test
# next test

1..0
# tests 0
# pass  0

# ok

@geekytime
Copy link

I'm having the same problem with Webpack-bundled tests. If a test fails, tape never gets the error. It just sits forever. I'm beginning to think it's actually a Webpack problem, not a tape problem.

I know it's been a while, but did anyone ever get anywhere with this?

@AsaAyers
Copy link

AsaAyers commented Aug 7, 2016

Unending tests are verified in process's exit event. Browsers never exit, so this never gets called. Node fires the event when there aren't any I/O requests and there aren't any timers scheduled.

@ljharb
Copy link
Collaborator

ljharb commented Aug 7, 2016

Seems like something we could watch for on the window unload event, when window is present?

@AsaAyers
Copy link

AsaAyers commented Aug 7, 2016

That would require the user to manually guess that the tests should be done and close the window, then you can pop up an "Are you sure you want to close this window?" prompt. I have completely abandoned Tape in browsers for this reason.

It's been months since I tried it, but I had something that launched the browser and ran the tests automatically. It would wait for Tape to give the signal that it's done before closing the window.

@ljharb
Copy link
Collaborator

ljharb commented Aug 8, 2016

@AsaAyers how would you propose a browser know when unending tests should be considered done?

@AsaAyers
Copy link

AsaAyers commented Aug 8, 2016

I don't believe there is any functional replacement for process.on('exit', that you can use in the browser. My best stab at a solution is that Tape starts individual tests and just waits for them to complete. I think it needs to be more proactive in setting a default timeout when in the browser and forcing that test to be marked as a failure so it can move on to the next test.

You may need to look into how other test runners manage this. I have only looked deep enough into the code to find the process.on('exit',

@sergueyarellano
Copy link

I'm having the same problem under jspm @geekytime . Any workaround here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants