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');
5
5
var Test = require ( './lib/test' ) ;
6
6
var createResult = require ( './lib/results' ) ;
7
7
var through = require ( '@ljharb/through' ) ;
8
+ var EventEmitter = require ( 'events' ) . EventEmitter ;
8
9
9
10
var canEmitExit = typeof process !== 'undefined' && process
10
11
&& typeof process . on === 'function' && process . browser !== true ;
@@ -53,6 +54,10 @@ module.exports = (function () {
53
54
return harness . createStream ( options ) ;
54
55
} ;
55
56
57
+ lazyLoad . async = function ( ) {
58
+ return getHarness ( ) . async . apply ( this , arguments ) ;
59
+ } ;
60
+
56
61
lazyLoad . onFinish = function ( ) {
57
62
return getHarness ( ) . onFinish . apply ( this , arguments ) ;
58
63
} ;
@@ -142,10 +147,15 @@ function createExitHarness(conf, wait) {
142
147
stream . on ( 'end' , function ( ) { ended = true ; } ) ;
143
148
}
144
149
150
+ run ( ) ;
151
+
145
152
if ( wait ) {
146
- harness . run = run ;
147
- } else {
148
- run ( ) ;
153
+ var waiter = new EventEmitter ( ) ;
154
+ waiter . run = function ( ) { } ;
155
+ harness . _results . push ( waiter ) ;
156
+ harness . run = function ( ) {
157
+ waiter . emit ( 'end' ) ;
158
+ } ;
149
159
}
150
160
151
161
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