6
6
* Transforms a testRoutine into an ava test.
7
7
* The testCommand function asserts that a given awaitable command produces the expected stdout and stderr.
8
8
*
9
+ * An absent `expectation.stdout` defaults to the empty string.
10
+ * An absent `expectation.stderr` now defaults to an accept-anything regexp
11
+ * in order to tolerate extra tool-generated noise that happens, for example,
12
+ * when run under a vscode JavaScript Debug Terminal
13
+ * @see https://github.com/endojs/endo/issues/2702
14
+ *
9
15
* @param {Execa } execa - the command execution environment
10
16
* @param {TestRoutine } testRoutine - the test logic implementation
11
17
* @returns {(t: t) => Promise<void> }
@@ -15,16 +21,16 @@ export function makeSectionTest(execa, testRoutine) {
15
21
const matchExpecation = ( expectation , result , errMsg ) => {
16
22
( expectation instanceof RegExp ? t . regex : t . is ) (
17
23
result ,
18
- expectation ?? '' ,
24
+ expectation ,
19
25
errMsg ,
20
26
) ;
21
27
} ;
22
28
const testCommand = async ( command , expectation ) => {
23
29
const result = await command ;
24
30
if ( expectation !== undefined ) {
25
31
const errMsg = JSON . stringify ( { expectation, result } , null , 2 ) ;
26
- matchExpecation ( expectation . stdout , result . stdout , errMsg ) ;
27
- matchExpecation ( expectation . stderr , result . stderr , errMsg ) ;
32
+ matchExpecation ( expectation . stdout ?? '' , result . stdout , errMsg ) ;
33
+ matchExpecation ( expectation . stderr ?? / . * / , result . stderr , errMsg ) ;
28
34
}
29
35
} ;
30
36
await testRoutine ( execa , testCommand ) ;
0 commit comments