@@ -14,6 +14,7 @@ const sinon = require("sinon");
14
14
const proxyquire = require ( "proxyquire" ) ;
15
15
const chalk = require ( "chalk" ) ;
16
16
const path = require ( "path" ) ;
17
+ const stripAnsi = require ( "strip-ansi" ) ;
17
18
18
19
// Chalk protects its methods so we need to inherit from it for Sinon to work.
19
20
const chalkStub = Object . create ( chalk , {
@@ -86,7 +87,7 @@ describe("formatter:codeframe", () => {
86
87
it ( "should return a string in the correct format for warnings" , ( ) => {
87
88
const result = formatter ( code ) ;
88
89
89
- assert . equal ( chalk . stripColor ( result ) , [
90
+ assert . equal ( stripAnsi ( result ) , [
90
91
`warning: Unexpected foo (foo) at ${ path . join ( "lib" , "foo.js" ) } :1:5:` ,
91
92
"> 1 | var foo = 1;" ,
92
93
" | ^" ,
@@ -115,7 +116,7 @@ describe("formatter:codeframe", () => {
115
116
it ( "should return a string in the correct format" , ( ) => {
116
117
const result = formatter ( code ) ;
117
118
118
- assert . equal ( chalk . stripColor ( result ) , [
119
+ assert . equal ( stripAnsi ( result ) , [
119
120
`warning: Unexpected foo (foo) at ${ path . join ( "lib" , "foo.js" ) } :1:5:` ,
120
121
"> 1 | var foo = 1;" ,
121
122
" | ^" ,
@@ -147,7 +148,7 @@ describe("formatter:codeframe", () => {
147
148
it ( "should return a string in the correct format for errors" , ( ) => {
148
149
const result = formatter ( code ) ;
149
150
150
- assert . equal ( chalk . stripColor ( result ) , [
151
+ assert . equal ( stripAnsi ( result ) , [
151
152
`error: Unexpected foo (foo) at ${ path . join ( "lib" , "foo.js" ) } :1:5:` ,
152
153
"> 1 | var foo = 1;" ,
153
154
" | ^" ,
@@ -193,7 +194,7 @@ describe("formatter:codeframe", () => {
193
194
it ( "should return a string with multiple entries" , ( ) => {
194
195
const result = formatter ( code ) ;
195
196
196
- assert . equal ( chalk . stripColor ( result ) , [
197
+ assert . equal ( stripAnsi ( result ) , [
197
198
"error: Missing semicolon (semi) at foo.js:1:14:" ,
198
199
"> 1 | const foo = 1" ,
199
200
" | ^" ,
@@ -241,7 +242,7 @@ describe("formatter:codeframe", () => {
241
242
it ( "should return a string with code preview pointing to the correct location after fixes" , ( ) => {
242
243
const result = formatter ( code ) ;
243
244
244
- assert . equal ( chalk . stripColor ( result ) , [
245
+ assert . equal ( stripAnsi ( result ) , [
245
246
"error: 'foo' is assigned a value but never used (no-unused-vars) at foo.js:4:11:" ,
246
247
" 2 | " ,
247
248
" 3 | // a comment" ,
@@ -286,7 +287,7 @@ describe("formatter:codeframe", () => {
286
287
it ( "should return a string with multiple entries" , ( ) => {
287
288
const result = formatter ( code ) ;
288
289
289
- assert . equal ( chalk . stripColor ( result ) , [
290
+ assert . equal ( stripAnsi ( result ) , [
290
291
"error: Missing semicolon (semi) at foo.js:1:14:" ,
291
292
"> 1 | const foo = 1" ,
292
293
" | ^" ,
@@ -322,7 +323,7 @@ describe("formatter:codeframe", () => {
322
323
it ( "should return a string in the correct format" , ( ) => {
323
324
const result = formatter ( code ) ;
324
325
325
- assert . equal ( chalk . stripColor ( result ) , [
326
+ assert . equal ( stripAnsi ( result ) , [
326
327
"error: Parsing error: Unexpected token { at foo.js:1:2:" ,
327
328
"> 1 | e{}" ,
328
329
" | ^" ,
@@ -347,7 +348,7 @@ describe("formatter:codeframe", () => {
347
348
it ( "should return a string without code preview (codeframe)" , ( ) => {
348
349
const result = formatter ( code ) ;
349
350
350
- assert . equal ( chalk . stripColor ( result ) , "error: Couldn't find foo.js at foo.js\n\n\n1 error found." ) ;
351
+ assert . equal ( stripAnsi ( result ) , "error: Couldn't find foo.js at foo.js\n\n\n1 error found." ) ;
351
352
} ) ;
352
353
} ) ;
353
354
@@ -367,13 +368,13 @@ describe("formatter:codeframe", () => {
367
368
it ( "should return a string without code preview (codeframe)" , ( ) => {
368
369
const result = formatter ( code ) ;
369
370
370
- assert . equal ( chalk . stripColor ( result ) , "error: Unexpected foo (foo) at foo.js\n\n\n1 error found." ) ;
371
+ assert . equal ( stripAnsi ( result ) , "error: Unexpected foo (foo) at foo.js\n\n\n1 error found." ) ;
371
372
} ) ;
372
373
373
374
it ( "should output filepath but without 'line:column' appended" , ( ) => {
374
375
const result = formatter ( code ) ;
375
376
376
- assert . equal ( chalk . stripColor ( result ) , "error: Unexpected foo (foo) at foo.js\n\n\n1 error found." ) ;
377
+ assert . equal ( stripAnsi ( result ) , "error: Unexpected foo (foo) at foo.js\n\n\n1 error found." ) ;
377
378
} ) ;
378
379
} ) ;
379
380
0 commit comments