Skip to content

Commit

Permalink
fix: error regression - strip ansi colors out of cy.fixture() error m…
Browse files Browse the repository at this point in the history
…essage (#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
  • Loading branch information
brian-mann committed Feb 28, 2022
1 parent ffd3627 commit e0bd6ac
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
1 change: 1 addition & 0 deletions npm/webpack-dev-server/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,4 @@ describe('#startDevServer', () => {
})
})
})
.timeout(5000)
6 changes: 6 additions & 0 deletions packages/driver/cypress/integration/commands/fixtures_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const stripAnsi = require('strip-ansi')

const { assertLogLength } = require('../../support/utils')
const { Promise } = Cypress

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

// ensure ansi color codes are not embedded in the error msg
// https://github.com/cypress-io/cypress/issues/20208
expect(err.message).to.eq(stripAnsi(err.message))

done()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('per-test config', () => {
})
})

describe('in mulitple nested suites', {
describe('in multiple nested suites', {
foo: false,
}, () => {
describe('config in suite', {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class $Cypress {
// and those leak out into the stdout formatting.
const errMsg = _.isString(errResult)
? errResult
: `Expected ${format(errResult.key)} to be ${errResult.type}.\n\nInstead the value was: ${stringify(errResult.value)}\``
: `Expected ${format(errResult.key)} to be ${errResult.type}.\n\nInstead the value was: ${stringify(errResult.value)}`

throw new this.state('specWindow').Error(errMsg)
})
Expand Down
11 changes: 10 additions & 1 deletion packages/server/lib/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const debug = require('debug')('cypress:server:fixture')
const coffee = require('coffeescript')
const Promise = require('bluebird')
const jsonlint = require('jsonlint')
const stripAnsi = require('strip-ansi')

const errors = require('./errors')
const { fs } = require('./util/fs')
const glob = require('./util/glob')
Expand Down Expand Up @@ -60,7 +62,14 @@ module.exports = {
if (matches.length === 0) {
const relativePath = path.relative('.', p)

errors.throw('FIXTURE_NOT_FOUND', relativePath, extensions)
// TODO: there's no reason this error should be in
// the @packages/error list, it should be written in
// the driver since this error can only occur within
// driver commands and not outside of the test runner
const err = errors.get('FIXTURE_NOT_FOUND', relativePath, extensions)

err.message = stripAnsi(err.message)
throw err
}

debug('fixture matches found, using the first', matches)
Expand Down
68 changes: 34 additions & 34 deletions system-tests/__snapshots__/testConfigOverrides_spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ exports['testConfigOverrides / fails when passing invalid config values - [chrom
1) inline test config override throws error:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`""\`\`
Instead the value was: \`""\`
[stack trace lines]
2) inline test config override throws error when executed within cy cmd:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"null"\`\`
Instead the value was: \`"null"\`
[stack trace lines]
3) context config overrides throws error
Expand All @@ -197,7 +197,7 @@ Instead the value was: \`"null"\`\`
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Error
Expand All @@ -209,7 +209,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
Error
Expand All @@ -221,7 +221,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
Error
Expand All @@ -234,7 +234,7 @@ https://on.cypress.io/config
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"not_an_http_url"\`\`
Instead the value was: \`"not_an_http_url"\`
https://on.cypress.io/config
Error
Expand All @@ -246,7 +246,7 @@ https://on.cypress.io/config
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Expand All @@ -260,7 +260,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Error
Expand Down Expand Up @@ -350,14 +350,14 @@ exports['testConfigOverrides / fails when passing invalid config values with bef
inline test config override throws error:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`""\`\`
Instead the value was: \`""\`
[stack trace lines]
2) runs all tests
inline test config override throws error when executed within cy cmd:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"null"\`\`
Instead the value was: \`"null"\`
[stack trace lines]
3) runs all tests
Expand All @@ -367,7 +367,7 @@ Instead the value was: \`"null"\`\`
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Error
Expand All @@ -380,7 +380,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
Error
Expand All @@ -393,7 +393,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
Error
Expand All @@ -407,7 +407,7 @@ https://on.cypress.io/config
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"not_an_http_url"\`\`
Instead the value was: \`"not_an_http_url"\`
https://on.cypress.io/config
Error
Expand All @@ -420,7 +420,7 @@ https://on.cypress.io/config
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Expand All @@ -435,7 +435,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Error
Expand Down Expand Up @@ -517,7 +517,7 @@ exports['testConfigOverrides / correctly fails when invalid config values for it
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Error
Expand Down Expand Up @@ -601,13 +601,13 @@ exports['testConfigOverrides / fails when passing invalid config values - [firef
1) inline test config override throws error:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`""\`\`
Instead the value was: \`""\`
[stack trace lines]
2) inline test config override throws error when executed within cy cmd:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"null"\`\`
Instead the value was: \`"null"\`
[stack trace lines]
3) context config overrides throws error
Expand All @@ -616,7 +616,7 @@ Instead the value was: \`"null"\`\`
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -627,7 +627,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -638,7 +638,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -650,7 +650,7 @@ https://on.cypress.io/config
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"not_an_http_url"\`\`
Instead the value was: \`"not_an_http_url"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -661,7 +661,7 @@ https://on.cypress.io/config
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Expand All @@ -674,7 +674,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
[stack trace lines]
Expand Down Expand Up @@ -763,14 +763,14 @@ exports['testConfigOverrides / fails when passing invalid config values with bef
inline test config override throws error:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`""\`\`
Instead the value was: \`""\`
[stack trace lines]
2) runs all tests
inline test config override throws error when executed within cy cmd:
Error: Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"null"\`\`
Instead the value was: \`"null"\`
[stack trace lines]
3) runs all tests
Expand All @@ -780,7 +780,7 @@ Instead the value was: \`"null"\`\`
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -792,7 +792,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -804,7 +804,7 @@ https://on.cypress.io/config
Expected \`defaultCommandTimeout\` to be a number.
Instead the value was: \`"500"\`\`
Instead the value was: \`"500"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -817,7 +817,7 @@ https://on.cypress.io/config
Expected \`baseUrl\` to be a fully qualified URL (starting with \`http://\` or \`https://\`).
Instead the value was: \`"not_an_http_url"\`\`
Instead the value was: \`"not_an_http_url"\`
https://on.cypress.io/config
[stack trace lines]
Expand All @@ -829,7 +829,7 @@ https://on.cypress.io/config
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
Expand All @@ -843,7 +843,7 @@ Because this error occurred during a \`before all\` hook we are skipping the rem
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
[stack trace lines]
Expand Down Expand Up @@ -924,7 +924,7 @@ exports['testConfigOverrides / correctly fails when invalid config values for it
Expected \`retries\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls.
Instead the value was: \`"1"\`\`
Instead the value was: \`"1"\`
https://on.cypress.io/config
[stack trace lines]
Expand Down

3 comments on commit e0bd6ac

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e0bd6ac Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/linux-x64/circle-develop-e0bd6ac2aaf8d00b9233fffefed8f6ed2484bf45/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e0bd6ac Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/win32-x64/circle-develop-e0bd6ac2aaf8d00b9233fffefed8f6ed2484bf45/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e0bd6ac Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/darwin-x64/circle-develop-e0bd6ac2aaf8d00b9233fffefed8f6ed2484bf45/cypress.tgz

Please sign in to comment.