File tree Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ var createDefaultStream = require('./lib/default_stream');
55var Test = require ( './lib/test' ) ;
66var createResult = require ( './lib/results' ) ;
77var through = require ( 'through' ) ;
8+ var EventEmitter = require ( 'events' ) . EventEmitter ;
89
910var canEmitExit = typeof process !== 'undefined' && process
1011 && typeof process . on === 'function' && process . browser !== true ;
@@ -43,6 +44,10 @@ module.exports = (function () {
4344 return harness . createStream ( options ) ;
4445 } ;
4546
47+ lazyLoad . async = function ( ) {
48+ return getHarness ( ) . async . apply ( this , arguments ) ;
49+ } ;
50+
4651 lazyLoad . onFinish = function ( ) {
4752 return getHarness ( ) . onFinish . apply ( this , arguments ) ;
4853 } ;
@@ -72,10 +77,15 @@ function createExitHarness(conf, wait) {
7277 var running = false ;
7378 var ended = false ;
7479
80+ run ( ) ;
81+
7582 if ( wait ) {
76- harness . run = run ;
77- } else {
78- run ( ) ;
83+ var waiter = new EventEmitter ( ) ;
84+ waiter . run = function ( ) { } ;
85+ harness . _results . push ( waiter ) ;
86+ harness . run = function ( ) {
87+ waiter . emit ( "end" ) ;
88+ }
7989 }
8090
8191 if ( config . exit === false ) { return harness ; }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var tap = require ( 'tap' ) ;
4+ var tape = require ( '../' ) ;
5+
6+ tap . test ( 'Create stream then import async tests' , function ( t ) {
7+ t . plan ( 3 ) ;
8+
9+ var actualTests = function ( ) {
10+ tape ( 'This one should pass' , function ( t1 ) {
11+ t1 . pass ( 'This one should pass' ) ;
12+ t1 . end ( ) ;
13+ } ) ;
14+ } ;
15+
16+ var simulateAsyncEsmImport = function ( ) {
17+ return new Promise ( function ( resolve ) {
18+ setTimeout ( function ( ) {
19+ actualTests ( ) ;
20+ resolve ( ) ;
21+ } ) ;
22+ } ) ;
23+ } ;
24+
25+ tape . createStream ( { objectMode : true } ) . on ( 'data' , function ( res ) {
26+ t . pass ( res . type ) ;
27+ } ) ;
28+
29+ tape . wait ( ) ;
30+ simulateAsyncEsmImport ( ) . then ( function ( ) {
31+ tape . run ( ) ;
32+ } ) ;
33+ } ) ;
You can’t perform that action at this time.
0 commit comments