Skip to content

Commit

Permalink
fix cy.visit error stack, magenta e2e test stdout, bump zip
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Dec 9, 2019
1 parent abe744c commit dfe48fa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/driver/src/cy/commands/navigation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
error: err
stack: err.stack
}
noStackTrace: true
})

visit = ->
Expand Down
5 changes: 5 additions & 0 deletions packages/driver/src/cypress/cy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
## collect all of the callbacks for 'fail'
rets = Cypress.action("cy:fail", err, state("runnable"))
catch err2
e = err2
errString = e.toString()
errStack = e.stack
if !errStack.slice(0, errStack.indexOf("\n")).includes(errString)
e.stack = errString + "\n" + e.stack
## and if any of these throw synchronously immediately error
finish(err2)

Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/cypress/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ module.exports = {
throwErr: (err, options = {}) ->
if _.isString(err)
err = @cypressErr(err)
if options.noStackTrace
err.stack = ''

onFail = options.onFail
errProps = options.errProps
Expand Down
24 changes: 19 additions & 5 deletions packages/server/test/support/helpers/e2e.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ path = require("path")
http = require("http")
human = require("human-interval")
morgan = require("morgan")
stream = require("stream")
chalk = require("chalk").default
express = require("express")
Promise = require("bluebird")
snapshot = require("snap-shot-it")
Expand Down Expand Up @@ -38,18 +40,20 @@ DEFAULT_BROWSERS = ['electron', 'chrome', 'firefox']
stackTraceLinesRe = /(\n?\s*).*?(@|at).*\.(js|coffee|ts|html|jsx|tsx)(-\d+)?:\d+:\d+[\n\S\s]*?(\n\s*?\n|$)/g
browserNameVersionRe = /(Browser\:\s+)(Custom |)(Electron|Chrome|Canary|Chromium|Firefox)(\s\d+)(\s\(\w+\))?(\s+)/
availableBrowsersRe = /(Available browsers found are: )(.+)/g
crossOriginErrorRe = /(Blocked a frame .* from accessing a cross-origin frame|Permission denied.*cross-origin object)/gm

currentOptions = {}

## this captures an entire stack trace and replaces it with [stack trace lines]
## so that the stdout can contain stack traces of different lengths
## '@' will be present in firefox stack trace lines
## 'at' will be present in chrome stack trace lines
replaceStackTraceLines = (str, browser) ->
replaceStackTraceLines = (str) ->
str.replace(stackTraceLinesRe, (match, parts...) ->
pre = parts[0]
isFirefoxStack = parts[1] is '@'
post = parts[4]
if browser is 'firefox'
if isFirefoxStack
if pre is '\n'
pre = '\n '
else
Expand All @@ -58,6 +62,10 @@ replaceStackTraceLines = (str, browser) ->
post = post.slice(-1)
return "#{pre}[stack trace lines]#{post}")

## Different browsers have different cross-origin error messages
replaceCrossOriginErorrMessages = (str) ->
str.replace crossOriginErrorRe, '[Cross origin error message]'

replaceBrowserName = (str, key, customBrowserPath, browserName, version, headless, whitespace) ->
## get the padding for the existing browser string
lengthOfExistingBrowserString = _.sum([browserName.length, version.length, _.get(headless, "length", 0), whitespace.length])
Expand Down Expand Up @@ -144,7 +152,7 @@ normalizeStdout = (str) ->
## screenshot dimensions
str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims)

return replaceStackTraceLines(str, options.browser)
return replaceStackTraceLines( replaceCrossOriginErorrMessages str)

ensurePort = (port) ->
if port is 5566
Expand Down Expand Up @@ -539,10 +547,16 @@ module.exports = e2e = {
.value()
}

ColorOutput = () ->
colorOutput = new stream.Transform()
colorOutput._transform = (chunk, encoding, cb) ->
cb(null, chalk.magenta(chunk.toString()))
colorOutput

## pipe these to our current process
## so we can see them in the terminal
sp.stdout.pipe(process.stdout)
sp.stderr.pipe(process.stderr)
sp.stdout.pipe(ColorOutput()).pipe(process.stdout)
sp.stderr.pipe(ColorOutput()).pipe(process.stderr)

sp.stdout.on "data", (buf) ->
stdout += buf.toString()
Expand Down
2 changes: 1 addition & 1 deletion scripts/binary/zip.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ checkZipSize = (zipPath) ->
stats = fs.statSync(zipPath)
zipSize = filesize(stats.size, {round: 0})
console.log("zip file size #{zipSize}")
MAX_ALLOWED_SIZE_MB = if os.platform() == "win32" then 275 else 180
MAX_ALLOWED_SIZE_MB = if os.platform() == "win32" then 275 else 185
MAX_ZIP_FILE_SIZE = megaBytes(MAX_ALLOWED_SIZE_MB)
if stats.size > MAX_ZIP_FILE_SIZE
throw new Error("Zip file is too large: #{zipSize} (#{stats.size} bytes) exceeds #{MAX_ZIP_FILE_SIZE} bytes")
Expand Down

1 comment on commit dfe48fa

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dfe48fa Dec 9, 2019

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.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.0/linux-x64/circle-issue-1096-firefox-support-dfe48fad8e31d7f9235b33ae5cf9ce65464d8803-211076/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.0/circle-issue-1096-firefox-support-dfe48fad8e31d7f9235b33ae5cf9ce65464d8803-211068/cypress.tgz

Please sign in to comment.