Skip to content

Commit

Permalink
Merge branch 'develop' into patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverJAsh committed Mar 24, 2020
2 parents 50ea3bc + d307e30 commit 19c6a24
Show file tree
Hide file tree
Showing 274 changed files with 6,317 additions and 3,820 deletions.
38 changes: 34 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers:node12.8.1-chrome80-ff72
- image: cypress/browsers:node12.13.0-chrome80-ff74
environment:
PLATFORM: linux

Expand Down Expand Up @@ -319,10 +319,10 @@ jobs:
command: ls -la types
working_directory: cli
- run:
command: ls -la chai
working_directory: cli/types
# Run dtslint, but permit failures for now as per https://github.com/cypress-io/cypress/pull/6819
command: yarn lerna exec --scope cypress "yarn dtslint" || true
- run:
command: yarn lerna exec --scope cypress "yarn dtslint"
command: yarn type-check --ignore-progress
- store-npm-logs

"server-unit-tests":
Expand Down Expand Up @@ -610,6 +610,11 @@ jobs:
at: ~/
- run:
command: yarn workspace @packages/desktop-gui build-prod
- run:
name: Desktop GUI server
command: yarn start
working_directory: packages/desktop-gui
background: true
- run:
command: |
CYPRESS_KONFIG_ENV=production \
Expand All @@ -621,6 +626,27 @@ jobs:
path: /tmp/artifacts
- store-npm-logs

desktop-gui-visual-tests:
<<: *defaults
parallelism: 1
steps:
- attach_workspace:
at: ~/
- run:
command: yarn lerna exec --scope @packages/desktop-gui "yarn build-prod"
- run:
name: Desktop GUI server
command: yarn start
working_directory: packages/desktop-gui
background: true
- run:
# will use PERCY_TOKEN environment variable if available
command: |
CYPRESS_KONFIG_ENV=production \
yarn lerna exec --scope @packages/desktop-gui "yarn percy exec -- yarn cypress:run --spec cypress/integration/settings_spec.js"
# we don't really need any artifacts - we are only interested in visual screenshots
- store-npm-logs

"reporter-integration-tests":
<<: *defaults
steps:
Expand Down Expand Up @@ -1232,6 +1258,9 @@ linux-workflow: &linux-workflow
- desktop-gui-integration-tests-2x:
requires:
- build
- desktop-gui-visual-tests:
requires:
- build
- reporter-integration-tests:
requires:
- build
Expand Down Expand Up @@ -1444,6 +1473,7 @@ mac-workflow: &mac-workflow
- post-pre-release-install-comment:
context: test-runner:commit-status-checks
name: Post Mac pre-release install comment
executor: mac
filters:
branches:
only:
Expand Down
4 changes: 4 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ yarn test-debug --scope cypress

This will take and compare snapshots of the CLI output. To update snapshots, see `snap-shot-it` instructions: https://github.com/bahmutov/snap-shot-it#advanced-use

#### Type Linting

When testing with `dtslint`, you may need to remove existing typescript installations before running the type linter (for instance, on OS X, you might `rm -rf ~/.dts/typescript-installs`) in order to reproduce issues with new versions of typescript (i.e., `@next`).

### Manual

To build and test an NPM package:
Expand Down
19 changes: 19 additions & 0 deletions cli/__snapshots__/spawn_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
exports['lib/exec/spawn .start forces colors and streams when supported 1'] = {
"FORCE_COLOR": "1",
"DEBUG_COLORS": "1",
"MOCHA_COLORS": "1",
"FORCE_STDIN_TTY": "1",
"FORCE_STDOUT_TTY": "1",
"FORCE_STDERR_TTY": "1",
"NODE_OPTIONS": "--max-http-header-size=1048576 --http-parser=legacy"
}

exports['lib/exec/spawn .start does not force colors and streams when not supported 1'] = {
"FORCE_COLOR": "0",
"DEBUG_COLORS": "0",
"FORCE_STDIN_TTY": "0",
"FORCE_STDOUT_TTY": "0",
"FORCE_STDERR_TTY": "0",
"NODE_OPTIONS": "--max-http-header-size=1048576 --http-parser=legacy"
}

exports['lib/exec/spawn .start detects kill signal exits with error on SIGKILL 1'] = `
The Test Runner unexpectedly exited via a exit event with signal SIGKILL
Expand Down
2 changes: 0 additions & 2 deletions cli/__snapshots__/verify_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ Cypress Version: 1.2.3
`

exports['fails verifying Cypress 1'] = `
It looks like this is your first time using Cypress: 1.2.3
✖ Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app
STRIPPED
Expand Down Expand Up @@ -309,7 +308,6 @@ Opening Cypress...
`

exports['verification with executable 1'] = `
It looks like this is your first time using Cypress: 1.2.3
✔ Verified Cypress! /cache/Cypress/1.2.3/Cypress.app
Expand Down
2 changes: 1 addition & 1 deletion cli/lib/exec/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {
}

const { onStderrData, electronLogging } = overrides
const envOverrides = util.getEnvOverrides()
const envOverrides = util.getEnvOverrides(options)
const electronArgs = _.clone(args)
const node11WindowsFix = isPlatform('win32')

Expand Down
2 changes: 1 addition & 1 deletion cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const os = require('os')
const url = require('url')
const path = require('path')
const debug = require('debug')('cypress:cli')
const request = require('request')
const request = require('@cypress/request')
const Promise = require('bluebird')
const requestProgress = require('request-progress')
const { stripIndent } = require('common-tags')
Expand Down
9 changes: 6 additions & 3 deletions cli/lib/tasks/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,12 @@ const runSmokeTest = (binaryDir, options) => {
function testBinary (version, binaryDir, options) {
debug('running binary verification check', version)

logger.log(stripIndent`
It looks like this is your first time using Cypress: ${chalk.cyan(version)}
`)
// if running from 'cypress verify', don't print this message
if (!options.force) {
logger.log(stripIndent`
It looks like this is your first time using Cypress: ${chalk.cyan(version)}
`)
}

logger.log()

Expand Down
28 changes: 27 additions & 1 deletion cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const util = {
return isCi
},

getEnvOverrides () {
getEnvOverrides (options = {}) {
return _
.chain({})
.extend(util.getEnvColors())
Expand All @@ -277,9 +277,35 @@ const util = {
.mapValues((value) => { // stringify to 1 or 0
return value ? '1' : '0'
})
.extend(util.getNodeOptions(options))
.value()
},

getNodeOptions (options, nodeVersion) {
if (!nodeVersion) {
nodeVersion = Number(process.versions.node.split('.')[0])
}

if (options.dev && nodeVersion < 12) {
// `node` is used instead of Electron when --dev is passed, so this won't work if Node is too old
debug('NODE_OPTIONS=--max-http-header-size could not be set because we\'re in dev mode and Node is < 12.0.0')

return
}

// https://github.com/cypress-io/cypress/issues/5431
const NODE_OPTIONS = `--max-http-header-size=${1024 ** 2} --http-parser=legacy`

if (_.isString(process.env.NODE_OPTIONS)) {
return {
NODE_OPTIONS: `${NODE_OPTIONS} ${process.env.NODE_OPTIONS}`,
ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS || '',
}
}

return { NODE_OPTIONS }
},

getForceTty () {
return {
FORCE_STDIN_TTY: util.isTty(process.stdin.fd),
Expand Down
26 changes: 13 additions & 13 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@
},
"dependencies": {
"@cypress/listr-verbose-renderer": "0.4.1",
"@cypress/request": "2.88.5",
"@cypress/xvfb": "1.2.4",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.29",
"@types/chai": "4.2.7",
"@types/chai-jquery": "1.1.40",
"@types/jquery": "3.3.31",
"@types/lodash": "4.14.149",
"@types/minimatch": "3.0.3",
"@types/mocha": "5.2.7",
"@types/sinon": "7.5.1",
"@types/sinon-chai": "3.2.3",
"@types/sizzle": "2.3.2",
"arch": "2.1.1",
"bluebird": "3.7.2",
Expand All @@ -44,12 +55,11 @@
"listr": "0.14.3",
"lodash": "4.17.15",
"log-symbols": "3.0.0",
"minimist": "1.2.0",
"minimist": "1.2.5",
"moment": "2.24.0",
"ospath": "1.2.2",
"pretty-bytes": "5.3.0",
"ramda": "0.26.1",
"request": "2.88.0",
"request-progress": "3.0.0",
"supports-color": "7.1.0",
"tmp": "0.1.0",
Expand All @@ -60,16 +70,6 @@
"devDependencies": {
"@cypress/sinon-chai": "1.1.0",
"@packages/root": "*",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.29",
"@types/chai": "4.2.7",
"@types/chai-jquery": "1.1.40",
"@types/jquery": "3.3.31",
"@types/lodash": "4.14.149",
"@types/minimatch": "3.0.3",
"@types/mocha": "5.2.7",
"@types/sinon": "7.5.1",
"@types/sinon-chai": "3.2.3",
"babel-cli": "6.26.0",
"babel-preset-es2015": "6.24.1",
"chai": "3.5.0",
Expand All @@ -83,7 +83,7 @@
"mocha": "6.2.2",
"mock-fs": "4.9.0",
"mocked-env": "1.2.4",
"nock": "9.6.1",
"nock": "12.0.2",
"postinstall-postinstall": "2.0.0",
"proxyquire": "2.1.0",
"resolve-pkg": "2.0.0",
Expand Down
90 changes: 27 additions & 63 deletions cli/scripts/post-install.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,28 @@
#!/usr/bin/env node

const { includeTypes } = require('./utils')
const shell = require('shelljs')
const { join } = require('path')
const resolvePkg = require('resolve-pkg')

shell.set('-v') // verbose
shell.set('-e') // any error is fatal

// We include the TypeScript definitions for the bundled 3rd party tools
// thus we need to copy them from "dev" dependencies into our types folder
// and we need to sometimes tweak these types files to use relative paths
// This ensures that globals like Cypress.$, Cypress._ etc are property typed
// yet we do not install "@types/.." packages with "npm install cypress"
// because they can conflict with user's own libraries

includeTypes.forEach((folder) => {
const source = resolvePkg(`@types/${folder}`, { cwd: join(__dirname, '..', '..') })

shell.cp('-R', source, 'types')
const fs = require('../lib/fs')
const path = require('path')

/**
* https://github.com/cypress-io/cypress/pull/5780
* Folder names in "node_modules/@types" that were copied to cli/types to generate index.d.ts.
* They cause type errors in type checker. So, they should be removed.
*/
const includeTypes = [
'blob-util',
'bluebird',
'lodash',
'mocha',
'minimatch',
'sinon',
'sinon-chai',
'chai',
'chai-jquery',
'jquery',
]

includeTypes.forEach((t) => {
const dir = path.join(__dirname, '../types', t)

if (fs.existsSync(dir)) {
fs.removeSync(dir)
}
})

// jQuery v3.3.x includes "dist" folder that just references back to itself
// causing dtslint to think there are double definitions. Remove that folder.
const typesJqueryDistFolder = join('types', 'jquery', 'dist')

shell.rm('-rf', typesJqueryDistFolder)

// fix paths to Chai, jQuery and other types to be relative
shell.sed(
'-i',
'<reference types="chai" />',
'<reference path="../chai/index.d.ts" />',
join('types', 'chai-jquery', 'index.d.ts'),
)

shell.sed(
'-i',
'<reference types="jquery" />',
'<reference path="../jquery/index.d.ts" />',
join('types', 'chai-jquery', 'index.d.ts'),
)

const sinonChaiFilename = join('types', 'sinon-chai', 'index.d.ts')

shell.sed(
'-i',
'<reference types="chai" />',
'<reference path="../chai/index.d.ts" />',
sinonChaiFilename,
)

// also use relative import via path for sinon-chai
// there is reference comment line we need to fix to be relative
shell.sed(
'-i',
'<reference types="sinon" />',
'<reference path="../sinon/index.d.ts" />',
sinonChaiFilename,
)

// and an import sinon line to be changed to relative path
shell.sed('-i', 'from \'sinon\';', 'from \'../sinon\';', sinonChaiFilename)
8 changes: 0 additions & 8 deletions cli/scripts/start-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env node

const { includeTypes } = require('./utils')
const { join } = require('path')
const shell = require('shelljs')

shell.set('-v') // verbose
Expand All @@ -15,12 +13,6 @@ shell.cp('NPM_README.md', 'build/README.md')
shell.cp('.release.json', 'build/.release.json')
// copies our typescript definitions
shell.cp('-R', 'types/*.ts', 'build/types/')
// copies 3rd party typescript definitions
includeTypes.forEach((folder) => {
const source = join('types', folder)

shell.cp('-R', source, 'build/types')
})

shell.exec('babel lib -d build/lib')
shell.exec('babel index.js -o build/index.js')

0 comments on commit 19c6a24

Please sign in to comment.