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

Calling createStream() more than once causes weird behavior on the first test. #105

Closed
aghassemi opened this issue Oct 1, 2014 · 4 comments

Comments

@aghassemi
Copy link
Contributor

I have a use-case where I need to create two streams, one in objectMode and one for raw TAP output, however calling createStream() twice has a side-effect where for the very first test in the suite, the state of whether it has ended or not is ignored making t.plan(x) not work properly in the first test.

var test = require('tape');

test.createStream(); // all good
test.createStream(); // this extra call causes "starting test 2" to show up before "finishing test 1"

test('test one', function (t) {
  t.plan(1);
  console.log('starting test 1');
  setTimeout( function() {
    console.log('finishing test 1');
    t.pass();
  }, 100);
});

test('test two', function (t) {
   console.log('starting test 2');
   t.end();
});
@nfcampos
Copy link

nfcampos commented Jan 1, 2016

I have the same problem (for the same reason, want both object mode and TAP output) and i'd created issue #230 because i didn't realise this issue existed.

Any update on this?

@geekytime
Copy link

Although this example is contrived, I discovered the same behavior when trying to run tests in the browser that also report results back to the CLI.

I'd like to use the object stream to render HTML results in the browser, while sending the TAP results back to the CLI app that kicks off the tests, so they can be properly streamed into other reporters.

@keithkml
Copy link

I ran into this issue in an attempt to use createStream to capture the name of the currently running test, for screenshot / logging purposes.

@nhamer
Copy link
Contributor

nhamer commented Oct 15, 2017

The issue is here: https://github.com/substack/tape/blob/b66f8f80928bb82f0817407880a139ad118daf01/lib/results.js#L68

The results stream is actually acting as the test-runner, so each stream picks off the common queue of pending tests - you could potentially have as many simultaneous tests as streams.

ljharb pushed a commit to nhamer/tape that referenced this issue Jan 28, 2019
ljharb pushed a commit to nhamer/tape that referenced this issue Jan 28, 2019
ljharb added a commit that referenced this issue Jan 28, 2019
[Fix]: only use one test runner for results, even if multiple streams are created

Fixes #105.
ljharb added a commit that referenced this issue Feb 9, 2019
[New] Implements TAP TODO directive (#254)
[New] add alias 'notDeepEquals' to 'notDeepEqual' function (#411)

[Fix] fix premature end of tests (and running sibling tests) when test includes subtests (#403, #222)
[Fix] only use one test runner for results, even if multiple streams are created (#404, #361, #105)
[Fix] windows: Show failure location even if driver letter is lowercase (#329)

[Docs] link to mixed tape (#445)
[Docs] Add electron-tap (#240)
[Docs] Add tape-promise into 'other' (#210)
[Docs] Mention [`flip-tape`](https://github.com/pguth/flip-tape/blob/master/README.md) in the section "other". (#359)
[Docs] Add an alternative ES6 tape runner (#328)
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

6 participants