From 02f59170122b1fbec4155aae2495291dc232aa6e Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 12:50:55 -0400 Subject: [PATCH 1/8] cli: set NODE_OPTIONS=--max-http-header-size=1024*1024 on spawn --- cli/__snapshots__/spawn_spec.js | 18 ++++++++++++++++ cli/lib/util.js | 14 +++++++++++++ cli/test/lib/exec/spawn_spec.js | 18 +++------------- cli/test/lib/util_spec.js | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 cli/__snapshots__/spawn_spec.js diff --git a/cli/__snapshots__/spawn_spec.js b/cli/__snapshots__/spawn_spec.js new file mode 100644 index 000000000000..f66c3f2b8b67 --- /dev/null +++ b/cli/__snapshots__/spawn_spec.js @@ -0,0 +1,18 @@ +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" +} + +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" +} diff --git a/cli/lib/util.js b/cli/lib/util.js index 84f872db4ce5..61d0645b6586 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -193,9 +193,23 @@ const util = { .mapValues((value) => { // stringify to 1 or 0 return value ? '1' : '0' }) + .extend(util.getNodeOptions()) .value() }, + getNodeOptions () { + // https://github.com/cypress-io/cypress/issues/5431 + const NODE_OPTIONS = `--max-http-header-size=${1024 * 1024}` + + if (_.isString(process.env.NODE_OPTIONS)) { + return { + NODE_OPTIONS: `${process.env.NODE_OPTIONS} ${NODE_OPTIONS}`, + } + } + + return { NODE_OPTIONS } + }, + getForceTty () { return { FORCE_STDIN_TTY: util.isTty(process.stdin.fd), diff --git a/cli/test/lib/exec/spawn_spec.js b/cli/test/lib/exec/spawn_spec.js index d66a12f85a71..01c159737345 100644 --- a/cli/test/lib/exec/spawn_spec.js +++ b/cli/test/lib/exec/spawn_spec.js @@ -3,6 +3,7 @@ require('../../spec_helper') const _ = require('lodash') const cp = require('child_process') const os = require('os') +const snapshot = require('snap-shot-it') const tty = require('tty') const path = require('path') const EE = require('events') @@ -287,14 +288,7 @@ describe('lib/exec/spawn', function () { return spawn.start([], { env: {} }) .then(() => { - expect(cp.spawn.firstCall.args[2].env).to.deep.eq({ - FORCE_COLOR: '1', - DEBUG_COLORS: '1', - MOCHA_COLORS: '1', - FORCE_STDERR_TTY: '1', - FORCE_STDIN_TTY: '1', - FORCE_STDOUT_TTY: '1', - }) + snapshot(cp.spawn.firstCall.args[2].env) }) }) @@ -326,13 +320,7 @@ describe('lib/exec/spawn', function () { return spawn.start([], { env: {} }) .then(() => { - expect(cp.spawn.firstCall.args[2].env).to.deep.eq({ - FORCE_COLOR: '0', - DEBUG_COLORS: '0', - FORCE_STDERR_TTY: '0', - FORCE_STDIN_TTY: '0', - FORCE_STDOUT_TTY: '0', - }) + snapshot(cp.spawn.firstCall.args[2].env) }) }) diff --git a/cli/test/lib/util_spec.js b/cli/test/lib/util_spec.js index 30be63f3a4c6..49349fcd09ee 100644 --- a/cli/test/lib/util_spec.js +++ b/cli/test/lib/util_spec.js @@ -3,6 +3,7 @@ require('../spec_helper') const os = require('os') const tty = require('tty') const snapshot = require('../support/snapshot') +const mockedEnv = require('mocked-env') const supportsColor = require('supports-color') const proxyquire = require('proxyquire') const hasha = require('hasha') @@ -11,6 +12,9 @@ const la = require('lazy-ass') const util = require(`${lib}/util`) const logger = require(`${lib}/logger`) +// https://github.com/cypress-io/cypress/issues/5431 +const expectedNodeOptions = `--max-http-header-size=${1024 * 1024}` + describe('util', () => { beforeEach(() => { sinon.stub(process, 'exit') @@ -213,6 +217,7 @@ describe('util', () => { FORCE_COLOR: '1', DEBUG_COLORS: '1', MOCHA_COLORS: '1', + NODE_OPTIONS: expectedNodeOptions, }) util.supportsColor.returns(false) @@ -224,6 +229,38 @@ describe('util', () => { FORCE_STDERR_TTY: '0', FORCE_COLOR: '0', DEBUG_COLORS: '0', + NODE_OPTIONS: expectedNodeOptions, + }) + }) + }) + + context('.getNodeOptions', () => { + let restoreEnv + + afterEach(() => { + if (restoreEnv) { + restoreEnv() + restoreEnv = null + } + }) + + it('adds required NODE_OPTIONS', () => { + restoreEnv = mockedEnv({ + NODE_OPTIONS: undefined, + }) + + expect(util.getNodeOptions()).to.deep.eq({ + NODE_OPTIONS: expectedNodeOptions, + }) + }) + + it('includes existing NODE_OPTIONS', () => { + restoreEnv = mockedEnv({ + NODE_OPTIONS: '--foo --bar', + }) + + expect(util.getNodeOptions()).to.deep.eq({ + NODE_OPTIONS: `--foo --bar ${expectedNodeOptions}`, }) }) }) From 352106577c46a7f73c1ae6ae9520dce7691fa248 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 12:52:19 -0400 Subject: [PATCH 2/8] electron: remove redundant max-http-header-size --- packages/electron/lib/electron.coffee | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/electron/lib/electron.coffee b/packages/electron/lib/electron.coffee index f1631e9353f5..28e02a8a3d04 100644 --- a/packages/electron/lib/electron.coffee +++ b/packages/electron/lib/electron.coffee @@ -75,10 +75,6 @@ module.exports = { if opts.inspectBrk argv.unshift("--inspect-brk=5566") - ## max HTTP header size 8kb -> 1mb - ## https://github.com/cypress-io/cypress/issues/76 - argv.unshift("--max-http-header-size=#{1024*1024}") - debug("spawning %s with args", execPath, argv) if debug.enabled From b08ee27c6183a43809357f023b6292522258bda7 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 12:53:16 -0400 Subject: [PATCH 3/8] server: add useCli option to make e2e tests go thru cli --- .../server/test/support/helpers/e2e.coffee | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/packages/server/test/support/helpers/e2e.coffee b/packages/server/test/support/helpers/e2e.coffee index d4c1fb89ffe8..c4e4610dcef8 100644 --- a/packages/server/test/support/helpers/e2e.coffee +++ b/packages/server/test/support/helpers/e2e.coffee @@ -73,7 +73,7 @@ replaceParenTime = (str, p1) -> return _.padStart("(X second)", p1.length) replaceScreenshotDims = (str, p1) -> - return _.padStart("(YxX)", p1.length) + return _.padStart("(YxX)", p1.length) replaceUploadingResults = (orig, match..., offset, string) -> results = match[1].split('\n').map((res) -> @@ -89,35 +89,35 @@ normalizeStdout = (str, options = {}) -> ## remove all of the dynamic parts of stdout ## to normalize against what we expected str = str - ## /Users/jane/........../ -> //foo/bar/.projects/ + ## /Users/jane/........../ -> //foo/bar/.projects/ ## (Required when paths are printed outside of our own formatting) .split(pathUpToProjectName).join("/foo/bar/.projects") .replace(availableBrowsersRe, "$1browser1, browser2, browser3") .replace(browserNameVersionRe, replaceBrowserName) ## numbers in parenths - .replace(/\s\(\d+([ms]|ms)\)/g, "") + .replace(/\s\(\d+([ms]|ms)\)/g, "") ## 12:35 -> XX:XX .replace(/(\s+?)(\d+ms|\d+:\d+:?\d+)/g, replaceDurationInTables) .replace(/(coffee|js)-\d{3}/g, "$1-456") ## Cypress: 2.1.0 -> Cypress: 1.2.3 - .replace(/(Cypress\:\s+)(\d\.\d\.\d)/g, "$1" + "1.2.3") + .replace(/(Cypress\:\s+)(\d\.\d\.\d)/g, "$1" + "1.2.3") ## Node Version: 10.2.3 (Users/jane/node) -> Node Version: X (foo/bar/node) - .replace(/(Node Version\:\s+v)(\d+\.\d+\.\d+)( \(.*\)\s+)/g, replaceNodeVersion) + .replace(/(Node Version\:\s+v)(\d+\.\d+\.\d+)( \(.*\)\s+)/g, replaceNodeVersion) ## 15 seconds -> X second .replace(/(Duration\:\s+)(\d+\sminutes?,\s+)?(\d+\sseconds?)(\s+)/g, replaceDurationSeconds) ## duration='1589' -> duration='XXXX' - .replace(/(duration\=\')(\d+)(\')/g, replaceDurationFromReporter) + .replace(/(duration\=\')(\d+)(\')/g, replaceDurationFromReporter) ## (15 seconds) -> (XX seconds) .replace(/(\((\d+ minutes?,\s+)?\d+ seconds?\))/g, replaceParenTime) .replace(/\r/g, "") ## replaces multiple lines of uploading results (since order not guaranteed) - .replace(/(Uploading Results.*?\n\n)((.*-.*[\s\S\r]){2,}?)(\n\n)/g, replaceUploadingResults) + .replace(/(Uploading Results.*?\n\n)((.*-.*[\s\S\r]){2,}?)(\n\n)/g, replaceUploadingResults) ## fix "Require stacks" for CI - .replace(/^(\- )(\/.*\/packages\/server\/)(.*)$/gm, "$1$3") + .replace(/^(\- )(\/.*\/packages\/server\/)(.*)$/gm, "$1$3") if options.sanitizeScreenshotDimensions ## screenshot dimensions - str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims) + str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims) return str.split("\n") .map(replaceStackTraceLines) @@ -126,7 +126,7 @@ normalizeStdout = (str, options = {}) -> ensurePort = (port) -> if port is 5566 throw new Error('Specified port cannot be on 5566 because it conflicts with --inspect-brk=5566') - + startServer = (obj) -> { onServer, port, https } = obj @@ -182,7 +182,7 @@ copy = -> ) getMochaItFn = (only, skip, browser, specifiedBrowser) -> - ## if we've been told to skip this test + ## if we've been told to skip this test ## or if we specified a particular browser and this ## doesn't match the one we're currently trying to run... if skip or (specifiedBrowser and specifiedBrowser isnt browser) @@ -193,13 +193,13 @@ getMochaItFn = (only, skip, browser, specifiedBrowser) -> return it.only return it - + getBrowsers = (generateTestsForDefaultBrowsers, browser, defaultBrowsers) -> ## if we're generating tests for default browsers if generateTestsForDefaultBrowsers ## then return an array of default browsers return defaultBrowsers - + ## but if we haven't been told to generate tests for default browsers ## and weren't provided a specified browser then throw if not browser @@ -226,7 +226,7 @@ localItFn = (title, options = {}) -> if not title throw new Error('e2e.it(...) must be passed a title as the first argument') - + ## LOGIC FOR AUTOGENERATING DYNAMIC TESTS ## - if generateTestsForDefaultBrowsers ## - create multiple tests for each default browser @@ -234,7 +234,7 @@ localItFn = (title, options = {}) -> ## ...skip the tests for each default browser if that browser ## ...does not match the specified one (used in CI) ## - else only generate a single test with the specified browser - + ## run the tests for all the default browsers, or if a browser ## has been specified, only run it for that specifiedBrowser = browser @@ -242,7 +242,7 @@ localItFn = (title, options = {}) -> browserToTest = (browser) -> mochaItFn = getMochaItFn(only, skip, browser, specifiedBrowser) - + testTitle = "#{title} [#{browser}]" mochaItFn testTitle, -> @@ -373,11 +373,20 @@ module.exports = e2e = { args: (options = {}) -> args = [ + "index.js", ## hides a user warning to go through NPM module "--cwd=#{process.cwd()}", "--run-project=#{options.project}" ] + if options.useCli + args = [ + "#{path.join(__dirname, '../../../../../cli/bin/cypress')}", + "run", + "--dev", + "--project=#{options.project}" + ] + if options.spec args.push("--spec=#{options.spec}") @@ -421,7 +430,9 @@ module.exports = e2e = { if options.outputPath args.push("--output-path", options.outputPath) - if options.exit? + if options.useCli and options.exit is false + args.push("--no-exit") + else if options.exit? args.push("--exit", options.exit) if options.inspectBrk @@ -442,8 +453,6 @@ module.exports = e2e = { options = @options(ctx, options) args = @args(options) - args = ["index.js"].concat(args) - stdout = "" stderr = "" From 35f864c0adb94a7f68a65ba253f6e3ee474030bd Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 12:55:33 -0400 Subject: [PATCH 4/8] server: add test for XHR with body > 100kb via CLI --- .../server/__snapshots__/4_xhr_spec.coffee.js | 11 ++++---- packages/server/test/e2e/4_xhr_spec.coffee | 1 + .../e2e/cypress/integration/xhr_spec.coffee | 27 +++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/packages/server/__snapshots__/4_xhr_spec.coffee.js b/packages/server/__snapshots__/4_xhr_spec.coffee.js index 82668ac7b044..a9b42a1a0c25 100644 --- a/packages/server/__snapshots__/4_xhr_spec.coffee.js +++ b/packages/server/__snapshots__/4_xhr_spec.coffee.js @@ -23,20 +23,21 @@ exports['e2e xhr / passes'] = ` ✓ does not inject into json's contents from http server even requesting text/html ✓ does not inject into json's contents from file server even requesting text/html ✓ works prior to visit + ✓ can stub a 100kb response server with 1 visit ✓ response body ✓ request body ✓ aborts - 8 passing + 9 passing (Results) ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 8 │ - │ Passing: 8 │ + │ Tests: 9 │ + │ Passing: 9 │ │ Failing: 0 │ │ Pending: 0 │ │ Skipped: 0 │ @@ -60,9 +61,9 @@ exports['e2e xhr / passes'] = ` Spec Tests Passing Failing Pending Skipped ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✔ xhr_spec.coffee XX:XX 8 8 - - - │ + │ ✔ xhr_spec.coffee XX:XX 9 9 - - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✔ All specs passed! XX:XX 8 8 - - - + ✔ All specs passed! XX:XX 9 9 - - - ` diff --git a/packages/server/test/e2e/4_xhr_spec.coffee b/packages/server/test/e2e/4_xhr_spec.coffee index 5d2a67b43308..6c812aed17b9 100644 --- a/packages/server/test/e2e/4_xhr_spec.coffee +++ b/packages/server/test/e2e/4_xhr_spec.coffee @@ -30,4 +30,5 @@ describe "e2e xhr", -> spec: "xhr_spec.coffee" snapshot: true expectedExitCode: 0 + useCli: true } diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/xhr_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/xhr_spec.coffee index ee5d09232511..de26aa8c3204 100644 --- a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/xhr_spec.coffee +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/xhr_spec.coffee @@ -76,6 +76,33 @@ describe "xhrs", -> it "works prior to visit", -> cy.server() + ## https://github.com/cypress-io/cypress/issues/5431 + it "can stub a 100kb response", (done) -> + body = 'X'.repeat(100 * 1024) + + cy.server() + cy.route({ + method: 'POST' + url: '/foo' + response: { + 'bar': body + } + }) + + cy.visit("/index.html") + .then (win) -> + xhr = new win.XMLHttpRequest + xhr.open("POST", "/foo") + xhr.send() + + finish = -> + expect(xhr.status).to.eq(200) + expect(xhr.responseText).to.include(body) + done() + + xhr.onload = finish + xhr.onerror = finish + describe "server with 1 visit", -> before -> cy.visit("/xhr.html") From 33df69403c0eeaf03a45352bc66c80221fc54510 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 13:06:53 -0400 Subject: [PATCH 5/8] clean up conditional --- packages/server/test/support/helpers/e2e.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/test/support/helpers/e2e.coffee b/packages/server/test/support/helpers/e2e.coffee index c4e4610dcef8..20c896e707e1 100644 --- a/packages/server/test/support/helpers/e2e.coffee +++ b/packages/server/test/support/helpers/e2e.coffee @@ -432,7 +432,8 @@ module.exports = e2e = { if options.useCli and options.exit is false args.push("--no-exit") - else if options.exit? + + if not options.useCli and options.exit? args.push("--exit", options.exit) if options.inspectBrk From 0975407d2724d618c2c656648f937214f1a2cb89 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 17:36:26 -0400 Subject: [PATCH 6/8] cli: don't pass --max-http-header-size in dev w node < 11.10 --- cli/lib/exec/spawn.js | 2 +- cli/lib/util.js | 13 ++++++++++--- cli/test/lib/util_spec.js | 10 ++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cli/lib/exec/spawn.js b/cli/lib/exec/spawn.js index 8b192708e2b4..9bb786b1933a 100644 --- a/cli/lib/exec/spawn.js +++ b/cli/lib/exec/spawn.js @@ -102,7 +102,7 @@ module.exports = { } const { onStderrData, electronLogging } = overrides - const envOverrides = util.getEnvOverrides() + const envOverrides = util.getEnvOverrides(options) const electronArgs = _.clone(args) const node11WindowsFix = isPlatform('win32') diff --git a/cli/lib/util.js b/cli/lib/util.js index 61d0645b6586..474d7b6c3e29 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -184,7 +184,7 @@ const util = { return isCi }, - getEnvOverrides () { + getEnvOverrides (options = {}) { return _ .chain({}) .extend(util.getEnvColors()) @@ -193,11 +193,18 @@ const util = { .mapValues((value) => { // stringify to 1 or 0 return value ? '1' : '0' }) - .extend(util.getNodeOptions()) + .extend(util.getNodeOptions(options)) .value() }, - getNodeOptions () { + getNodeOptions (options) { + if (options.dev && Number(process.versions.node.split('.', 2).join('.')) < 11.10) { + // `node` is used when --dev is passed, so this won't work if Node is too old + logger.warn('(dev-mode warning only) NODE_OPTIONS=--max-http-header-size could not be set. See https://github.com/cypress-io/cypress/pull/5452') + + return + } + // https://github.com/cypress-io/cypress/issues/5431 const NODE_OPTIONS = `--max-http-header-size=${1024 * 1024}` diff --git a/cli/test/lib/util_spec.js b/cli/test/lib/util_spec.js index 49349fcd09ee..9305d6ec579b 100644 --- a/cli/test/lib/util_spec.js +++ b/cli/test/lib/util_spec.js @@ -249,7 +249,7 @@ describe('util', () => { NODE_OPTIONS: undefined, }) - expect(util.getNodeOptions()).to.deep.eq({ + expect(util.getNodeOptions({})).to.deep.eq({ NODE_OPTIONS: expectedNodeOptions, }) }) @@ -259,10 +259,16 @@ describe('util', () => { NODE_OPTIONS: '--foo --bar', }) - expect(util.getNodeOptions()).to.deep.eq({ + expect(util.getNodeOptions({})).to.deep.eq({ NODE_OPTIONS: `--foo --bar ${expectedNodeOptions}`, }) }) + + it('does not return if dev is set', () => { + expect(util.getNodeOptions({ + dev: true, + })).to.be.undefined + }) }) context('.getForceTty', () => { From eab3ddf825facf681f5c665d53bd738ea62590b4 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 17:54:20 -0400 Subject: [PATCH 7/8] add original_node_options to restore o.g. user node_options --- cli/lib/util.js | 11 ++++++++--- cli/test/lib/util_spec.js | 7 ++++--- packages/server/index.js | 13 ++++++++----- packages/server/lib/util/reset_node_options.ts | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 packages/server/lib/util/reset_node_options.ts diff --git a/cli/lib/util.js b/cli/lib/util.js index 474d7b6c3e29..488d3f436698 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -197,8 +197,12 @@ const util = { .value() }, - getNodeOptions (options) { - if (options.dev && Number(process.versions.node.split('.', 2).join('.')) < 11.10) { + getNodeOptions (options, nodeVersion) { + if (!nodeVersion) { + nodeVersion = Number(process.versions.node.split('.')[0]) + } + + if (options.dev && nodeVersion < 12) { // `node` is used when --dev is passed, so this won't work if Node is too old logger.warn('(dev-mode warning only) NODE_OPTIONS=--max-http-header-size could not be set. See https://github.com/cypress-io/cypress/pull/5452') @@ -210,7 +214,8 @@ const util = { if (_.isString(process.env.NODE_OPTIONS)) { return { - NODE_OPTIONS: `${process.env.NODE_OPTIONS} ${NODE_OPTIONS}`, + NODE_OPTIONS: `${NODE_OPTIONS} ${process.env.NODE_OPTIONS}`, + ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS || '', } } diff --git a/cli/test/lib/util_spec.js b/cli/test/lib/util_spec.js index 9305d6ec579b..ddcb545eded8 100644 --- a/cli/test/lib/util_spec.js +++ b/cli/test/lib/util_spec.js @@ -260,14 +260,15 @@ describe('util', () => { }) expect(util.getNodeOptions({})).to.deep.eq({ - NODE_OPTIONS: `--foo --bar ${expectedNodeOptions}`, + NODE_OPTIONS: `${expectedNodeOptions} --foo --bar`, + ORIGINAL_NODE_OPTIONS: '--foo --bar', }) }) - it('does not return if dev is set', () => { + it('does not return if dev is set and version < 12', () => { expect(util.getNodeOptions({ dev: true, - })).to.be.undefined + }, 11)).to.be.undefined }) }) diff --git a/packages/server/index.js b/packages/server/index.js index 7fe552991e8b..43bc65079000 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,3 +1,11 @@ +// if running in production mode (CYPRESS_ENV) +// all transpile should have been done already +// and these calls should do nothing +require('@packages/ts/register') +require('@packages/coffee/register') + +require('./lib/util/reset_node_options').reset() + // override tty if we're being forced to require('./lib/util/tty').override() @@ -9,11 +17,6 @@ if (process.env.CY_NET_PROFILE && process.env.CYPRESS_ENV) { process.env.UV_THREADPOOL_SIZE = 128 require('graceful-fs').gracefulify(require('fs')) -// if running in production mode (CYPRESS_ENV) -// all transpile should have been done already -// and these calls should do nothing -require('@packages/ts/register') -require('@packages/coffee/register') require && require.extensions && delete require.extensions['.litcoffee'] require && require.extensions && delete require.extensions['.coffee.md'] diff --git a/packages/server/lib/util/reset_node_options.ts b/packages/server/lib/util/reset_node_options.ts new file mode 100644 index 000000000000..3d864316c49f --- /dev/null +++ b/packages/server/lib/util/reset_node_options.ts @@ -0,0 +1,17 @@ +/** + * Once the Electron process is launched, restore the user's original NODE_OPTIONS + * environment variables from before the CLI added extra NODE_OPTIONS. + * + * This way, any `node` processes launched by Cypress will retain the user's + * `NODE_OPTIONS` without unexpected modificiations that could cause issues with + * user code. + */ + +export function reset () { + // @ts-ignore + if (process.versions.electron && typeof process.env.ORIGINAL_NODE_OPTIONS === 'string') { + process.env.NODE_OPTIONS = process.env.ORIGINAL_NODE_OPTIONS + + delete process.env.ORIGINAL_NODE_OPTIONS + } +} From e63a9bcace8afb2fa71429802a6b08d219289b4d Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 24 Oct 2019 18:32:30 -0400 Subject: [PATCH 8/8] force no color --- packages/server/test/support/helpers/e2e.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/test/support/helpers/e2e.coffee b/packages/server/test/support/helpers/e2e.coffee index 20c896e707e1..edec8dcbc83b 100644 --- a/packages/server/test/support/helpers/e2e.coffee +++ b/packages/server/test/support/helpers/e2e.coffee @@ -504,8 +504,7 @@ module.exports = e2e = { env: _.chain(process.env) .omit("CYPRESS_DEBUG") .extend({ - ## FYI: color will be disabled - ## because we are piping the child process + NO_COLOR: 1 COLUMNS: 100 LINES: 24 })