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

"timeout" and "t.timeoutAfter" documentation / error messages. #188

Open
dmin opened this issue Sep 5, 2015 · 0 comments
Open

"timeout" and "t.timeoutAfter" documentation / error messages. #188

dmin opened this issue Sep 5, 2015 · 0 comments

Comments

@dmin
Copy link

dmin commented Sep 5, 2015

The documentation doesn't give any specific information on when/how to use the timeout option or t.timeoutAfter method. I looked at the test for t.timeoutAfter but that still doesn't give much information on a real world usage. I attempted to use the timeout option in two different ways: are either of the following uses as intended (they both produce unexpected results)? Either way I'd be happy to put in a PR with a little more information on using timeout - just would like to get a little more insight on the intended usage. Original PR for timeoutAfter: #132.

Using t.plan

var test = require('tape');

test('one equals one', { timeout: 10 }, function (t) {

    t.plan(1);

    setTimeout(function () {
      t.equal(1, 1);
    }, 100);
});

Output:

TAP version 13
# one equals one
not ok 1 test timed out after 10ms
  ---
    operator: fail
  ...
ok 2 should be equal
not ok 3 plan != count
  ---
    operator: fail
    expected: 1
    actual:   2
    at: null._onTimeout (/Users/David/code/tests/tape-react/source/timeout-option-plan.js:8:9)
  ...

1..3
# tests 3
# pass  1
# fail  2

Using t.end

var test = require('tape');

test('two equals two', { timeout: 10 }, function (t) {

    t.equal("two", "two");

    setTimeout(function () {
      t.end();
    }, 100);
});

Output

TAP version 13
# two equals two
ok 1 should be equal
not ok 2 test timed out after 10ms
  ---
    operator: fail
  ...
not ok 3 .end() called twice
  ---
    operator: fail
    at: null._onTimeout (/Users/David/code/tests/tape-react/source/timeout-option-end.js:8:9)
  ...

1..3
# tests 3
# pass  1
# fail  2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants