@@ -14,14 +14,14 @@ function typeName(value) {
14
14
const child = new ChildProcess ( ) ;
15
15
16
16
[ undefined , null , 'foo' , 0 , 1 , NaN , true , false ] . forEach ( ( options ) => {
17
- assert . throws ( ( ) => {
17
+ common . expectsError ( ( ) => {
18
18
child . spawn ( options ) ;
19
- } , common . expectsError ( {
19
+ } , {
20
20
code : 'ERR_INVALID_ARG_TYPE' ,
21
21
type : TypeError ,
22
22
message : 'The "options" argument must be of type object. ' +
23
23
`Received type ${ typeName ( options ) } `
24
- } ) ) ;
24
+ } ) ;
25
25
} ) ;
26
26
}
27
27
@@ -30,14 +30,14 @@ function typeName(value) {
30
30
const child = new ChildProcess ( ) ;
31
31
32
32
[ undefined , null , 0 , 1 , NaN , true , false , { } ] . forEach ( ( file ) => {
33
- assert . throws ( ( ) => {
33
+ common . expectsError ( ( ) => {
34
34
child . spawn ( { file } ) ;
35
- } , common . expectsError ( {
35
+ } , {
36
36
code : 'ERR_INVALID_ARG_TYPE' ,
37
37
type : TypeError ,
38
38
message : 'The "options.file" property must be of type string. ' +
39
39
`Received type ${ typeName ( file ) } `
40
- } ) ) ;
40
+ } ) ;
41
41
} ) ;
42
42
}
43
43
@@ -46,14 +46,14 @@ function typeName(value) {
46
46
const child = new ChildProcess ( ) ;
47
47
48
48
[ null , 0 , 1 , NaN , true , false , { } , 'foo' ] . forEach ( ( envPairs ) => {
49
- assert . throws ( ( ) => {
49
+ common . expectsError ( ( ) => {
50
50
child . spawn ( { envPairs, stdio : [ 'ignore' , 'ignore' , 'ignore' , 'ipc' ] } ) ;
51
- } , common . expectsError ( {
51
+ } , {
52
52
code : 'ERR_INVALID_ARG_TYPE' ,
53
53
type : TypeError ,
54
- message : 'The "options.envPairs" property must be of type array . ' +
54
+ message : 'The "options.envPairs" property must be of type Array . ' +
55
55
`Received type ${ typeName ( envPairs ) } `
56
- } ) ) ;
56
+ } ) ;
57
57
} ) ;
58
58
}
59
59
@@ -62,14 +62,14 @@ function typeName(value) {
62
62
const child = new ChildProcess ( ) ;
63
63
64
64
[ null , 0 , 1 , NaN , true , false , { } , 'foo' ] . forEach ( ( args ) => {
65
- assert . throws ( ( ) => {
65
+ common . expectsError ( ( ) => {
66
66
child . spawn ( { file : 'foo' , args } ) ;
67
- } , common . expectsError ( {
67
+ } , {
68
68
code : 'ERR_INVALID_ARG_TYPE' ,
69
69
type : TypeError ,
70
- message : 'The "options.args" property must be of type array . ' +
70
+ message : 'The "options.args" property must be of type Array . ' +
71
71
`Received type ${ typeName ( args ) } `
72
- } ) ) ;
72
+ } ) ;
73
73
} ) ;
74
74
}
75
75
@@ -86,8 +86,9 @@ assert.strictEqual(child.hasOwnProperty('pid'), true);
86
86
assert ( Number . isInteger ( child . pid ) ) ;
87
87
88
88
// try killing with invalid signal
89
- assert . throws ( ( ) => {
90
- child . kill ( 'foo' ) ;
91
- } , common . expectsError ( { code : 'ERR_UNKNOWN_SIGNAL' , type : TypeError } ) ) ;
89
+ common . expectsError (
90
+ ( ) => { child . kill ( 'foo' ) ; } ,
91
+ { code : 'ERR_UNKNOWN_SIGNAL' , type : TypeError }
92
+ ) ;
92
93
93
94
assert . strictEqual ( child . kill ( ) , true ) ;
0 commit comments