22require ( '../common' ) ;
33const assert = require ( 'assert' ) . strict ;
44
5- assert . throws ( ( ) => {
5+ function setup ( ) {
66 process . env . FORCE_COLOR = '1' ;
77 delete process . env . NODE_DISABLE_COLORS ;
88 delete process . env . NO_COLOR ;
9+ }
10+
11+ assert . throws ( ( ) => {
12+ setup ( ) ;
913 assert . deepStrictEqual ( [ 1 , 2 , 2 , 2 , 2 ] , [ 2 , 2 , 2 , 2 , 2 ] ) ;
1014} , ( err ) => {
1115 const expected = 'Expected values to be strictly deep-equal:\n' +
@@ -19,6 +23,64 @@ assert.throws(() => {
1923 '\x1B[39m 2,\n' +
2024 '\x1B[31m-\x1B[39m 2\n' +
2125 '\x1B[39m ]\n' ;
26+
2227 assert . strictEqual ( err . message , expected ) ;
2328 return true ;
2429} ) ;
30+
31+ {
32+ // TODO(puskin94): remove the emitWarning override once the partialDeepStrictEqual method is not experimental anymore
33+ // Suppress warnings, necessary otherwise the tools/pseudo-tty.py runner will fail
34+ const originalEmitWarning = process . emitWarning ;
35+ process . emitWarning = ( ) => { } ;
36+
37+ assert . throws ( ( ) => {
38+ setup ( ) ;
39+ assert . partialDeepStrictEqual ( [ 1 , 2 , 3 , 5 ] , [ 4 , 5 ] ) ;
40+ } , ( err ) => {
41+ const expected = 'Expected values to be partially and strictly deep-equal:\n' +
42+ '\x1B[90mactual\x1B[39m \x1B[31m- expected\x1B[39m\n' +
43+ '\n' +
44+ '\x1B[39m [\n' +
45+ '\x1B[90m 1,\x1B[39m\n' +
46+ '\x1B[90m 2,\x1B[39m\n' +
47+ '\x1B[90m 3,\x1B[39m\n' +
48+ '\x1B[31m-\x1B[39m 4,\n' +
49+ '\x1B[39m 5\n' +
50+ '\x1B[39m ]\n' ;
51+
52+ assert . strictEqual ( err . message , expected ) ;
53+ return true ;
54+ } ) ;
55+
56+ process . emitWarning = originalEmitWarning ; // Restore original process.emitWarning
57+ }
58+
59+ {
60+ // TODO(puskin94): remove the emitWarning override once the partialDeepStrictEqual method is not experimental anymore
61+ // Suppress warnings, necessary otherwise the tools/pseudo-tty.py runner will fail
62+ const originalEmitWarning = process . emitWarning ;
63+ process . emitWarning = ( ) => { } ;
64+
65+ assert . throws ( ( ) => {
66+ setup ( ) ;
67+ assert . partialDeepStrictEqual ( { a : 1 , b : 2 , c : 3 , d : 5 } , { z : 4 , b : 5 } ) ;
68+ } , ( err ) => {
69+ const expected = 'Expected values to be partially and strictly deep-equal:\n' +
70+ '\x1B[90mactual\x1B[39m \x1B[31m- expected\x1B[39m\n' +
71+ '\n' +
72+ '\x1B[39m {\n' +
73+ '\x1B[90m a: 1,\x1B[39m\n' +
74+ '\x1B[90m b: 2,\x1B[39m\n' +
75+ '\x1B[90m c: 3,\x1B[39m\n' +
76+ '\x1B[90m d: 5\x1B[39m\n' +
77+ '\x1B[31m-\x1B[39m b: 5,\n' +
78+ '\x1B[31m-\x1B[39m z: 4\n' +
79+ '\x1B[39m }\n' ;
80+
81+ assert . strictEqual ( err . message , expected ) ;
82+ return true ;
83+ } ) ;
84+
85+ process . emitWarning = originalEmitWarning ; // Restore original process.emitWarning
86+ }
0 commit comments