File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ const schtasksResponses: { code: number; stdout: string; stderr: string }[] = []
1313// `finally` block deletes the temp file. Indexed by the position in
1414// `schtasksCalls` so individual tests can pin which create-call they assert on.
1515const xmlPayloadCaptures : Array < { index : number ; xml : string } > = [ ] ;
16+ const childUnref = vi . hoisted ( ( ) => vi . fn ( ) ) ;
17+ const spawn = vi . hoisted ( ( ) => vi . fn ( ( ) => ( { unref : childUnref } ) ) ) ;
18+
19+ vi . mock ( "node:child_process" , async ( ) => {
20+ const actual = await vi . importActual < typeof import ( "node:child_process" ) > ( "node:child_process" ) ;
21+ return { ...actual , spawn } ;
22+ } ) ;
1623
1724vi . mock ( "./schtasks-exec.js" , ( ) => ( {
1825 execSchtasks : async ( argv : string [ ] ) => {
@@ -39,6 +46,9 @@ beforeEach(() => {
3946 schtasksCalls . length = 0 ;
4047 schtasksResponses . length = 0 ;
4148 xmlPayloadCaptures . length = 0 ;
49+ childUnref . mockReset ( ) ;
50+ spawn . mockReset ( ) ;
51+ spawn . mockImplementation ( ( ) => ( { unref : childUnref } ) ) ;
4252} ) ;
4353
4454describe ( "installScheduledTask" , ( ) => {
You can’t perform that action at this time.
0 commit comments