@@ -155,7 +155,6 @@ test('prettyDOM can include all elements with a custom filter', () => {
155
155
156
156
test ( 'prettyDOM supports a COLORS environment variable' , ( ) => {
157
157
const { container} = render ( '<div>Hello World!</div>' )
158
-
159
158
const noColors = prettyDOM ( container , undefined , { highlight : false } )
160
159
const withColors = prettyDOM ( container , undefined , { highlight : true } )
161
160
@@ -167,6 +166,48 @@ test('prettyDOM supports a COLORS environment variable', () => {
167
166
expect ( prettyDOM ( container ) ) . toEqual ( withColors )
168
167
} )
169
168
169
+ test ( 'prettyDOM handles a COLORS env variable of unexpected object type by colorizing for node' , ( ) => {
170
+ const { container} = render ( '<div>Hello World!</div>' )
171
+ const noColors = prettyDOM ( container , undefined , { highlight : false } )
172
+ const withColors = prettyDOM ( container , undefined , { highlight : true } )
173
+
174
+ const originalNodeVersion = process . versions . node
175
+ process . env . COLORS = '{}'
176
+ delete process . versions . node
177
+ expect ( prettyDOM ( container ) ) . toEqual ( noColors )
178
+ process . versions . node = '1.2.3'
179
+ expect ( prettyDOM ( container ) ) . toEqual ( withColors )
180
+ process . versions . node = originalNodeVersion
181
+ } )
182
+
183
+ test ( 'prettyDOM handles a COLORS env variable of undefined by colorizing for node' , ( ) => {
184
+ const { container} = render ( '<div>Hello World!</div>' )
185
+ const noColors = prettyDOM ( container , undefined , { highlight : false } )
186
+ const withColors = prettyDOM ( container , undefined , { highlight : true } )
187
+
188
+ const originalNodeVersion = process . versions . node
189
+ process . env . COLORS = undefined
190
+ delete process . versions . node
191
+ expect ( prettyDOM ( container ) ) . toEqual ( noColors )
192
+ process . versions . node = '1.2.3'
193
+ expect ( prettyDOM ( container ) ) . toEqual ( withColors )
194
+ process . versions . node = originalNodeVersion
195
+ } )
196
+
197
+ test ( 'prettyDOM handles a COLORS env variable of empty string by colorizing for node' , ( ) => {
198
+ const { container} = render ( '<div>Hello World!</div>' )
199
+ const noColors = prettyDOM ( container , undefined , { highlight : false } )
200
+ const withColors = prettyDOM ( container , undefined , { highlight : true } )
201
+
202
+ const originalNodeVersion = process . versions . node
203
+ process . env . COLORS = ''
204
+ delete process . versions . node
205
+ expect ( prettyDOM ( container ) ) . toEqual ( noColors )
206
+ process . versions . node = '1.2.3'
207
+ expect ( prettyDOM ( container ) ) . toEqual ( withColors )
208
+ process . versions . node = originalNodeVersion
209
+ } )
210
+
170
211
test ( 'prettyDOM supports named custom elements' , ( ) => {
171
212
window . customElements . define (
172
213
'my-element-1' ,
0 commit comments