Skip to content

Commit e0bd6ac

Browse files
authored
fix: error regression - strip ansi colors out of cy.fixture() error message (#20335)
* fix cy.fixture regression - strip ansi colors out of fixture error message * empty commit to appease the semantic release gods * fix 2nd regression formatting when setting invalid config values - remove extra backtick * increase webpack dev server timeout values
1 parent ffd3627 commit e0bd6ac

File tree

6 files changed

+53
-37
lines changed

6 files changed

+53
-37
lines changed

npm/webpack-dev-server/test/e2e.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,4 @@ describe('#startDevServer', () => {
187187
})
188188
})
189189
})
190+
.timeout(5000)

packages/driver/cypress/integration/commands/fixtures_spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const stripAnsi = require('strip-ansi')
2+
13
const { assertLogLength } = require('../../support/utils')
24
const { Promise } = Cypress
35

@@ -130,6 +132,10 @@ describe('src/cy/commands/fixtures', () => {
130132
expect(err.message).to.include('A fixture file could not be found')
131133
expect(err.message).to.include('cypress/fixtures/err')
132134

135+
// ensure ansi color codes are not embedded in the error msg
136+
// https://github.com/cypress-io/cypress/issues/20208
137+
expect(err.message).to.eq(stripAnsi(err.message))
138+
133139
done()
134140
})
135141

packages/driver/cypress/integration/e2e/testConfigOverrides_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ describe('per-test config', () => {
243243
})
244244
})
245245

246-
describe('in mulitple nested suites', {
246+
describe('in multiple nested suites', {
247247
foo: false,
248248
}, () => {
249249
describe('config in suite', {

packages/driver/src/cypress.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class $Cypress {
251251
// and those leak out into the stdout formatting.
252252
const errMsg = _.isString(errResult)
253253
? errResult
254-
: `Expected ${format(errResult.key)} to be ${errResult.type}.\n\nInstead the value was: ${stringify(errResult.value)}\``
254+
: `Expected ${format(errResult.key)} to be ${errResult.type}.\n\nInstead the value was: ${stringify(errResult.value)}`
255255

256256
throw new this.state('specWindow').Error(errMsg)
257257
})

packages/server/lib/fixture.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const debug = require('debug')('cypress:server:fixture')
44
const coffee = require('coffeescript')
55
const Promise = require('bluebird')
66
const jsonlint = require('jsonlint')
7+
const stripAnsi = require('strip-ansi')
8+
79
const errors = require('./errors')
810
const { fs } = require('./util/fs')
911
const glob = require('./util/glob')
@@ -60,7 +62,14 @@ module.exports = {
6062
if (matches.length === 0) {
6163
const relativePath = path.relative('.', p)
6264

63-
errors.throw('FIXTURE_NOT_FOUND', relativePath, extensions)
65+
// TODO: there's no reason this error should be in
66+
// the @packages/error list, it should be written in
67+
// the driver since this error can only occur within
68+
// driver commands and not outside of the test runner
69+
const err = errors.get('FIXTURE_NOT_FOUND', relativePath, extensions)
70+
71+
err.message = stripAnsi(err.message)
72+
throw err
6473
}
6574

6675
debug('fixture matches found, using the first', matches)

system-tests/__snapshots__/testConfigOverrides_spec.ts.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ exports['testConfigOverrides / fails when passing invalid config values - [chrom
182182
1) inline test config override throws error:
183183
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
184184
185-
Instead the value was: \`""\`\`
185+
Instead the value was: \`""\`
186186
[stack trace lines]
187187
188188
2) inline test config override throws error when executed within cy cmd:
189189
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
190190
191-
Instead the value was: \`"null"\`\`
191+
Instead the value was: \`"null"\`
192192
[stack trace lines]
193193
194194
3) context config overrides throws error
@@ -197,7 +197,7 @@ Instead the value was: \`"null"\`\`
197197
198198
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
199199
200-
Instead the value was: \`"1"\`\`
200+
Instead the value was: \`"1"\`
201201
202202
https://on.cypress.io/config
203203
Error
@@ -209,7 +209,7 @@ https://on.cypress.io/config
209209
210210
Expected \`defaultCommandTimeout\` to be a number.
211211
212-
Instead the value was: \`"500"\`\`
212+
Instead the value was: \`"500"\`
213213
214214
https://on.cypress.io/config
215215
Error
@@ -221,7 +221,7 @@ https://on.cypress.io/config
221221
222222
Expected \`defaultCommandTimeout\` to be a number.
223223
224-
Instead the value was: \`"500"\`\`
224+
Instead the value was: \`"500"\`
225225
226226
https://on.cypress.io/config
227227
Error
@@ -234,7 +234,7 @@ https://on.cypress.io/config
234234
235235
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
236236
237-
Instead the value was: \`"not_an_http_url"\`\`
237+
Instead the value was: \`"not_an_http_url"\`
238238
239239
https://on.cypress.io/config
240240
Error
@@ -246,7 +246,7 @@ https://on.cypress.io/config
246246
247247
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
248248
249-
Instead the value was: \`"1"\`\`
249+
Instead the value was: \`"1"\`
250250
251251
https://on.cypress.io/config
252252
@@ -260,7 +260,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
260260
261261
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
262262
263-
Instead the value was: \`"1"\`\`
263+
Instead the value was: \`"1"\`
264264
265265
https://on.cypress.io/config
266266
Error
@@ -350,14 +350,14 @@ exports['testConfigOverrides / fails when passing invalid config values with bef
350350
inline test config override throws error:
351351
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
352352
353-
Instead the value was: \`""\`\`
353+
Instead the value was: \`""\`
354354
[stack trace lines]
355355
356356
2) runs all tests
357357
inline test config override throws error when executed within cy cmd:
358358
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
359359
360-
Instead the value was: \`"null"\`\`
360+
Instead the value was: \`"null"\`
361361
[stack trace lines]
362362
363363
3) runs all tests
@@ -367,7 +367,7 @@ Instead the value was: \`"null"\`\`
367367
368368
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
369369
370-
Instead the value was: \`"1"\`\`
370+
Instead the value was: \`"1"\`
371371
372372
https://on.cypress.io/config
373373
Error
@@ -380,7 +380,7 @@ https://on.cypress.io/config
380380
381381
Expected \`defaultCommandTimeout\` to be a number.
382382
383-
Instead the value was: \`"500"\`\`
383+
Instead the value was: \`"500"\`
384384
385385
https://on.cypress.io/config
386386
Error
@@ -393,7 +393,7 @@ https://on.cypress.io/config
393393
394394
Expected \`defaultCommandTimeout\` to be a number.
395395
396-
Instead the value was: \`"500"\`\`
396+
Instead the value was: \`"500"\`
397397
398398
https://on.cypress.io/config
399399
Error
@@ -407,7 +407,7 @@ https://on.cypress.io/config
407407
408408
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
409409
410-
Instead the value was: \`"not_an_http_url"\`\`
410+
Instead the value was: \`"not_an_http_url"\`
411411
412412
https://on.cypress.io/config
413413
Error
@@ -420,7 +420,7 @@ https://on.cypress.io/config
420420
421421
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
422422
423-
Instead the value was: \`"1"\`\`
423+
Instead the value was: \`"1"\`
424424
425425
https://on.cypress.io/config
426426
@@ -435,7 +435,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
435435
436436
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
437437
438-
Instead the value was: \`"1"\`\`
438+
Instead the value was: \`"1"\`
439439
440440
https://on.cypress.io/config
441441
Error
@@ -517,7 +517,7 @@ exports['testConfigOverrides / correctly fails when invalid config values for it
517517
518518
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
519519
520-
Instead the value was: \`"1"\`\`
520+
Instead the value was: \`"1"\`
521521
522522
https://on.cypress.io/config
523523
Error
@@ -601,13 +601,13 @@ exports['testConfigOverrides / fails when passing invalid config values - [firef
601601
1) inline test config override throws error:
602602
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
603603
604-
Instead the value was: \`""\`\`
604+
Instead the value was: \`""\`
605605
[stack trace lines]
606606
607607
2) inline test config override throws error when executed within cy cmd:
608608
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
609609
610-
Instead the value was: \`"null"\`\`
610+
Instead the value was: \`"null"\`
611611
[stack trace lines]
612612
613613
3) context config overrides throws error
@@ -616,7 +616,7 @@ Instead the value was: \`"null"\`\`
616616
617617
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
618618
619-
Instead the value was: \`"1"\`\`
619+
Instead the value was: \`"1"\`
620620
621621
https://on.cypress.io/config
622622
[stack trace lines]
@@ -627,7 +627,7 @@ https://on.cypress.io/config
627627
628628
Expected \`defaultCommandTimeout\` to be a number.
629629
630-
Instead the value was: \`"500"\`\`
630+
Instead the value was: \`"500"\`
631631
632632
https://on.cypress.io/config
633633
[stack trace lines]
@@ -638,7 +638,7 @@ https://on.cypress.io/config
638638
639639
Expected \`defaultCommandTimeout\` to be a number.
640640
641-
Instead the value was: \`"500"\`\`
641+
Instead the value was: \`"500"\`
642642
643643
https://on.cypress.io/config
644644
[stack trace lines]
@@ -650,7 +650,7 @@ https://on.cypress.io/config
650650
651651
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
652652
653-
Instead the value was: \`"not_an_http_url"\`\`
653+
Instead the value was: \`"not_an_http_url"\`
654654
655655
https://on.cypress.io/config
656656
[stack trace lines]
@@ -661,7 +661,7 @@ https://on.cypress.io/config
661661
662662
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
663663
664-
Instead the value was: \`"1"\`\`
664+
Instead the value was: \`"1"\`
665665
666666
https://on.cypress.io/config
667667
@@ -674,7 +674,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
674674
675675
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
676676
677-
Instead the value was: \`"1"\`\`
677+
Instead the value was: \`"1"\`
678678
679679
https://on.cypress.io/config
680680
[stack trace lines]
@@ -763,14 +763,14 @@ exports['testConfigOverrides / fails when passing invalid config values with bef
763763
inline test config override throws error:
764764
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
765765
766-
Instead the value was: \`""\`\`
766+
Instead the value was: \`""\`
767767
[stack trace lines]
768768
769769
2) runs all tests
770770
inline test config override throws error when executed within cy cmd:
771771
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
772772
773-
Instead the value was: \`"null"\`\`
773+
Instead the value was: \`"null"\`
774774
[stack trace lines]
775775
776776
3) runs all tests
@@ -780,7 +780,7 @@ Instead the value was: \`"null"\`\`
780780
781781
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
782782
783-
Instead the value was: \`"1"\`\`
783+
Instead the value was: \`"1"\`
784784
785785
https://on.cypress.io/config
786786
[stack trace lines]
@@ -792,7 +792,7 @@ https://on.cypress.io/config
792792
793793
Expected \`defaultCommandTimeout\` to be a number.
794794
795-
Instead the value was: \`"500"\`\`
795+
Instead the value was: \`"500"\`
796796
797797
https://on.cypress.io/config
798798
[stack trace lines]
@@ -804,7 +804,7 @@ https://on.cypress.io/config
804804
805805
Expected \`defaultCommandTimeout\` to be a number.
806806
807-
Instead the value was: \`"500"\`\`
807+
Instead the value was: \`"500"\`
808808
809809
https://on.cypress.io/config
810810
[stack trace lines]
@@ -817,7 +817,7 @@ https://on.cypress.io/config
817817
818818
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
819819
820-
Instead the value was: \`"not_an_http_url"\`\`
820+
Instead the value was: \`"not_an_http_url"\`
821821
822822
https://on.cypress.io/config
823823
[stack trace lines]
@@ -829,7 +829,7 @@ https://on.cypress.io/config
829829
830830
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
831831
832-
Instead the value was: \`"1"\`\`
832+
Instead the value was: \`"1"\`
833833
834834
https://on.cypress.io/config
835835
@@ -843,7 +843,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
843843
844844
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
845845
846-
Instead the value was: \`"1"\`\`
846+
Instead the value was: \`"1"\`
847847
848848
https://on.cypress.io/config
849849
[stack trace lines]
@@ -924,7 +924,7 @@ exports['testConfigOverrides / correctly fails when invalid config values for it
924924
925925
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
926926
927-
Instead the value was: \`"1"\`\`
927+
Instead the value was: \`"1"\`
928928
929929
https://on.cypress.io/config
930930
[stack trace lines]

0 commit comments

Comments
 (0)