File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,22 @@ export async function match(
77 /** Measured in ms */
88 timeout ?: number ;
99 } = { } ,
10- ) : Promise < string > {
10+ ) : Promise < RegExpMatchArray > {
1111 // Prepare error outside of promise so that stacktrace points to caller of `matchLine`
12- const timeout = new Error ( `Timed out - Could not find pattern: ${ pattern } ` ) ;
13- return new Promise < string > ( async ( resolve , reject ) => {
14- setTimeout ( ( ) => reject ( timeout ) , options . timeout ?? 10_000 ) ;
12+ const timeoutError = new Error (
13+ `Timed out - Could not find pattern: ${ pattern } ` ,
14+ ) ;
15+ return new Promise ( async ( resolve , reject ) => {
16+ const timeout = setTimeout (
17+ ( ) => reject ( timeoutError ) ,
18+ options . timeout ?? 10_000 ,
19+ ) ;
1520 stream . on ( "data" , ( data ) => {
1621 const line : string = data . toString ( ) ;
1722 const matches = line . match ( pattern ) ;
1823 if ( matches ) {
19- resolve ( matches [ 0 ] ) ;
24+ resolve ( matches ) ;
25+ clearTimeout ( timeout ) ;
2026 }
2127 } ) ;
2228 } ) ;
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ import { expect } from "@playwright/test";
33import getPort from "get-port" ;
44import dedent from "dedent" ;
55
6+ import * as Express from "./helpers/express" ;
67import { test } from "./helpers/fixtures" ;
78import * as Stream from "./helpers/stream" ;
89import { viteMajorTemplates , getTemplates } from "./helpers/templates" ;
9- import * as Express from "./helpers/express" ;
1010
1111const tsx = dedent ;
1212const mdx = dedent ;
@@ -71,6 +71,7 @@ templates.forEach((template) => {
7171
7272 const port = await getPort ( ) ;
7373 const url = `http://localhost:${ port } ` ;
74+
7475 const server = $ ( "node server.mjs" , {
7576 env : {
7677 PORT : String ( port ) ,
You can’t perform that action at this time.
0 commit comments