4
4
import * as os from 'os' ;
5
5
import * as ch from 'child_process' ;
6
6
import * as net from 'net' ;
7
- import { mocked } from 'ts-jest/utils' ;
8
7
import * as events from 'events' ;
9
8
import * as stream from 'stream' ;
10
9
import { ChildProcess } from 'child_process' ;
@@ -39,17 +38,17 @@ describe('getSpawnArgs', () => {
39
38
const getSpawnArgsTests = [
40
39
{
41
40
name : 'Linux' ,
42
- before : ( ) => mocked ( os . type ) . mockReturnValue ( 'Linux' ) ,
41
+ before : ( ) => ( os . type as jest . Mock ) . mockReturnValue ( 'Linux' ) ,
43
42
output : [ 'netstat' , [ '-anpt' ] ] ,
44
43
} ,
45
44
{
46
45
name : 'Darwin' ,
47
- before : ( ) => mocked ( os . type ) . mockReturnValue ( 'Darwin' ) ,
46
+ before : ( ) => ( os . type as jest . Mock ) . mockReturnValue ( 'Darwin' ) ,
48
47
output : [ 'netstat' , [ '-anvp' , 'tcp' ] ] ,
49
48
} ,
50
49
{
51
50
name : 'Windows_NT' ,
52
- before : ( ) => mocked ( os . type ) . mockReturnValue ( 'Windows_NT' ) ,
51
+ before : ( ) => ( os . type as jest . Mock ) . mockReturnValue ( 'Windows_NT' ) ,
53
52
output : [ 'netstat.exe' , [ '-a' , '-n' , '-o' ] ] ,
54
53
} ,
55
54
] ;
@@ -67,8 +66,8 @@ describe('getSpawnArgs', () => {
67
66
68
67
describe ( 'getRunningProcesses' , ( ) => {
69
68
beforeEach ( ( ) => {
70
- mocked ( os . type ) . mockReturnValue ( 'Linux' ) ;
71
- mocked ( ch . spawn ) . mockReturnValue ( mockChildProcess ) ;
69
+ ( os . type as jest . Mock ) . mockReturnValue ( 'Linux' ) ;
70
+ ( ch . spawn as jest . Mock ) . mockReturnValue ( mockChildProcess ) ;
72
71
} ) ;
73
72
const getRunningProcessesTests = [
74
73
{
@@ -94,7 +93,7 @@ describe('getRunningProcesses', () => {
94
93
} ) ;
95
94
96
95
it ( 'Should throw an error for unsupported platform' , async ( ) => {
97
- mocked ( os . type ) . mockReturnValueOnce ( 'custom_os' ) ;
96
+ ( os . type as jest . Mock ) . mockReturnValueOnce ( 'custom_os' ) ;
98
97
99
98
try {
100
99
await autodiscoveryUtility . getRunningProcesses ( ) ;
@@ -172,7 +171,7 @@ describe('getTCPEndpoints', () => {
172
171
173
172
describe ( 'testEndpoint' , ( ) => {
174
173
beforeEach ( ( ) => {
175
- mocked ( net . createConnection ) . mockReturnValue ( mockSocket ) ;
174
+ ( net . createConnection as jest . Mock ) . mockReturnValue ( mockSocket ) ;
176
175
} ) ;
177
176
const testEndpointTests = [
178
177
{
@@ -224,7 +223,7 @@ describe('getAvailableEndpoints', () => {
224
223
beforeEach ( ( ) => {
225
224
const getRunningProcessesSpy = jest . spyOn ( autodiscoveryUtility , 'getRunningProcesses' ) ;
226
225
getRunningProcessesSpy . mockResolvedValue ( [ '' ] ) ;
227
- mocked ( net . createConnection ) . mockReturnValue ( mockSocket ) ;
226
+ ( net . createConnection as jest . Mock ) . mockReturnValue ( mockSocket ) ;
228
227
} ) ;
229
228
const getAvailableEndpointsTests = [
230
229
{
0 commit comments