Skip to content

Commit

Permalink
Merge branch '10.0-release' into tgriesser/refactor/error-improvements
Browse files Browse the repository at this point in the history
* 10.0-release:
  fix: restore @lmiller1990's changes
  feat: styling snapshots (#19972)
  fix bad merge overrides- GOOD CATCH TYLER!
  fix(unify): Updating reporter to consistently use app-provided "Preferred Editor" dialog (#19933)
  fix: move node 17 Check from Binary to CLI (#19977)
  fix: pass correct spec URL in `cypress run` on Windows (#19890)
  fix: send click event with `cy.type('{enter}')`. (#19726)
  feat: detect package manager in wizard (#19960)
  fix: refactor set specs by specPattern (#19953)
  chore: Update Chrome (beta) to 98.0.4758.74
  • Loading branch information
tgriesser committed Feb 1, 2022
2 parents 9a94f0c + 7a7ddc3 commit 36e48c3
Show file tree
Hide file tree
Showing 62 changed files with 1,042 additions and 558 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"NOTESTS",
"OVERLIMIT",
"Pinia",
"pnpm",
"Screenshotting",
"shiki",
"testid",
Expand Down
2 changes: 1 addition & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "98.0.4758.66",
"chrome:beta": "98.0.4758.74",
"chrome:stable": "97.0.4692.99"
}
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ mainBuildFilters: &mainBuildFilters
only:
- develop
- 10.0-release
- test-binary-downstream-windows

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand Down
31 changes: 24 additions & 7 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ const executable = require('executable')
const { stripIndent } = require('common-tags')
const supportsColor = require('supports-color')
const isInstalledGlobally = require('is-installed-globally')
const pkg = require(path.join(__dirname, '..', 'package.json'))
const logger = require('./logger')
const debug = require('debug')('cypress:cli')
const fs = require('./fs')
const semver = require('semver')

const pkg = require(path.join(__dirname, '..', 'package.json'))

const issuesUrl = 'https://github.com/cypress-io/cypress/issues'

Expand Down Expand Up @@ -291,18 +293,33 @@ const util = {
.mapValues((value) => { // stringify to 1 or 0
return value ? '1' : '0'
})
.extend(util.getOriginalNodeOptions(options))
.extend(util.getOriginalNodeOptions())
.value()
},

getOriginalNodeOptions (options) {
getOriginalNodeOptions () {
const opts = {}

if (process.env.NODE_OPTIONS) {
return {
ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS,
}
opts.ORIGINAL_NODE_OPTIONS = process.env.NODE_OPTIONS
}

// https://github.com/cypress-io/cypress/issues/18914
// Node 17+ ships with OpenSSL 3 by default, so we may need the option
// --openssl-legacy-provider so that webpack@4 can use the legacy MD4 hash
// function. This option doesn't exist on Node <17 or when it is built
// against OpenSSL 1, so we have to detect Node's major version and check
// which version of OpenSSL it was built against before spawning the plugins
// process.

// To be removed when the Cypress binary pulls in the @cypress/webpack-batteries-included-preprocessor
// version that has been updated to webpack >= 5.61, which no longer relies on
// Node's builtin crypto.hash function.
if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && process.versions.openssl.startsWith('3.')) {
opts.ORIGINAL_NODE_OPTIONS = `${opts.ORIGINAL_NODE_OPTIONS || ''} --openssl-legacy-provider`
}

return {}
return opts
},

getForceTty () {
Expand Down
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"pretty-bytes": "^5.6.0",
"proxy-from-env": "1.0.0",
"request-progress": "^3.0.0",
"semver": "^7.3.2",
"supports-color": "^8.1.1",
"tmp": "~0.2.1",
"untildify": "^4.0.0",
Expand Down
66 changes: 66 additions & 0 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ describe('util', () => {

context('.getOriginalNodeOptions', () => {
let restoreEnv
const sandbox = sinon.createSandbox()

afterEach(() => {
if (restoreEnv) {
Expand All @@ -266,6 +267,9 @@ describe('util', () => {
})

it('copy NODE_OPTIONS to ORIGINAL_NODE_OPTIONS', () => {
sandbox.stub(process.versions, 'node').value('v16.5.0')
sandbox.stub(process.versions, 'openssl').value('1.0.0')

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})
Expand All @@ -274,6 +278,68 @@ describe('util', () => {
ORIGINAL_NODE_OPTIONS: '--require foo.js',
})
})

// https://github.com/cypress-io/cypress/issues/18914
it('includes --openssl-legacy-provider in Node 17+ w/ OpenSSL 3', () => {
sandbox.stub(process.versions, 'node').value('v17.1.0')
sandbox.stub(process.versions, 'openssl').value('3.0.0-quic')

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js --openssl-legacy-provider')

restoreEnv()
restoreEnv = mockedEnv({})
childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq(' --openssl-legacy-provider')
})

// https://github.com/cypress-io/cypress/issues/19320
it('does not include --openssl-legacy-provider in Node 17+ w/ OpenSSL 1', () => {
sandbox.stub(process.versions, 'node').value('v17.1.0')
sandbox.stub(process.versions, 'openssl').value('1.0.0')

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')

restoreEnv()
restoreEnv = mockedEnv({})
childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined
})

// https://github.com/cypress-io/cypress/issues/18914
it('does not include --openssl-legacy-provider in Node <=16', () => {
sandbox.stub(process.versions, 'node').value('v16.5.0')
sandbox.stub(process.versions, 'openssl').value('1.0.0')

restoreEnv = mockedEnv({})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')
})
})

context('.exit', () => {
Expand Down
1 change: 0 additions & 1 deletion npm/cypress-schematic/sandbox/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ chrome-profiler-events*.json
.history/*

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
Expand Down
2 changes: 1 addition & 1 deletion npm/cypress-schematic/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"karma-jasmine-html-reporter": "^1.5.0",
"typescript": "~4.5.5"
}
}
}
12 changes: 12 additions & 0 deletions npm/cypress-schematic/sandbox/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
* BROWSER POLYFILLS
*/

/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.

/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
Expand Down
4 changes: 1 addition & 3 deletions npm/cypress-schematic/sandbox/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ declare const require: {
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false },
},
platformBrowserDynamicTesting(),
)

// Then we find all the tests.
Expand Down
90 changes: 90 additions & 0 deletions packages/app/cypress/e2e/runner/reporter.errors.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { verify } from './support/verify-helpers'

describe('errors ui', {
viewportHeight: 768,
viewportWidth: 1024,
}, () => {
describe('assertion failures', () => {
beforeEach(() => {
cy.scaffoldProject('runner-e2e-specs')
cy.openProject('runner-e2e-specs')

// set preferred editor to bypass IDE selection dialog
cy.withCtx((ctx) => {
ctx.coreData.localSettings.availableEditors = [
...ctx.coreData.localSettings.availableEditors,
{
id: 'test-editor',
binary: '/usr/bin/test-editor',
name: 'Test editor',
},
]

ctx.coreData.localSettings.preferences.preferredEditorBinary = 'test-editor'
})

cy.startAppServer()
cy.visitApp()

cy.contains('[data-cy=spec-item]', 'assertions.cy.js').click()

cy.location().should((location) => {
expect(location.hash).to.contain('assertions.cy.js')
})

// Wait for specs to complete
cy.findByLabelText('Stats').get('.failed', { timeout: 10000 }).should('have.text', 'Failed:3')
})

verify.it('with expect().<foo>', {
file: 'assertions.cy.js',
hasPreferredIde: true,
column: 25,
message: `expected 'actual' to equal 'expected'`,
codeFrameText: 'with expect().<foo>',
})

verify.it('with assert()', {
file: 'assertions.cy.js',
hasPreferredIde: true,
column: '(5|12)', // (chrome|firefox)
message: `should be true`,
codeFrameText: 'with assert()',
})

verify.it('with assert.<foo>()', {
file: 'assertions.cy.js',
hasPreferredIde: true,
column: 12,
message: `expected 'actual' to equal 'expected'`,
codeFrameText: 'with assert.<foo>()',
})
})

describe('assertion failures - no preferred IDE', () => {
beforeEach(() => {
cy.scaffoldProject('runner-e2e-specs')
cy.openProject('runner-e2e-specs')

cy.startAppServer()
cy.visitApp()

cy.contains('[data-cy=spec-item]', 'assertions.cy.js').click()

cy.location().should((location) => {
expect(location.hash).to.contain('assertions.cy.js')
})

// Wait for specs to complete
cy.findByLabelText('Stats').get('.failed', { timeout: 10000 }).should('have.text', 'Failed:3')
})

verify.it('with expect().<foo>', {
file: 'assertions.cy.js',
hasPreferredIde: false,
column: 25,
message: `expected 'actual' to equal 'expected'`,
codeFrameText: 'with expect().<foo>',
})
})
})
Loading

0 comments on commit 36e48c3

Please sign in to comment.