11import { deepEqual , deepStrictEqual , notStrictEqual , rejects , strictEqual , throws } from 'node:assert' ;
2+ import child_process from 'node:child_process' ;
23import { readFileSync } from 'node:fs' ;
34import https from 'node:https' ;
45import { Agent , RequestOptions } from 'node:https' ;
56import path , { dirname , join } from 'node:path' ;
67import { fileURLToPath } from 'node:url' ;
8+ import { mock } from 'node:test' ;
79
810import mockfs from 'mock-fs' ;
911
@@ -324,7 +326,6 @@ describe('KubeConfig', () => {
324326 } ;
325327
326328 assertRequestOptionsEqual ( opts , expectedOptions ) ;
327- console . log ( requestContext . getAgent ( ) ) ;
328329 strictEqual ( ( requestContext . getAgent ( ) ! as any ) . options . servername , 'kube.example2.com' ) ;
329330 } ) ;
330331 it ( 'should apply cert configs' , async ( ) => {
@@ -1637,10 +1638,10 @@ describe('KubeConfig', () => {
16371638 it ( 'should try to load from WSL on Windows with wsl.exe not working' , ( ) => {
16381639 const kc = new KubeConfig ( ) ;
16391640 const commands : { command : string ; args : string [ ] } [ ] = [ ] ;
1640- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1641+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
16411642 commands . push ( { command : cmd , args } ) ;
16421643 return { status : 1 , stderr : 'some error' } ;
1643- } ;
1644+ } ) ;
16441645 kc . loadFromDefault ( undefined , false , 'win32' ) ;
16451646 strictEqual ( commands . length , 2 ) ;
16461647 for ( let i = 0 ; i < commands . length ; i ++ ) {
@@ -1657,10 +1658,10 @@ describe('KubeConfig', () => {
16571658 { status : 0 , stderr : '' , stdout : configData . toString ( ) } ,
16581659 ] ;
16591660 let ix = 0 ;
1660- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1661+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
16611662 commands . push ( { command : cmd , args } ) ;
16621663 return results [ ix ++ ] ;
1663- } ;
1664+ } ) ;
16641665 kc . loadFromDefault ( undefined , false , 'win32' ) ;
16651666 strictEqual ( commands . length , 2 ) ;
16661667 for ( let i = 0 ; i < commands . length ; i ++ ) {
@@ -1678,10 +1679,10 @@ describe('KubeConfig', () => {
16781679 { status : 0 , stderr : '' , stdout : 'C:\\wsldata\\.kube' } ,
16791680 ] ;
16801681 let ix = 0 ;
1681- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1682+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
16821683 commands . push ( { command : cmd , args } ) ;
16831684 return results [ ix ++ ] ;
1684- } ;
1685+ } ) ;
16851686 kc . loadFromDefault ( undefined , false , 'win32' ) ;
16861687 strictEqual ( commands . length , 3 ) ;
16871688 for ( let i = 0 ; i < commands . length ; i ++ ) {
0 commit comments