Skip to content

Commit

Permalink
Merge branch 'develop' into zachw/issue-22525
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 authored Jul 21, 2022
2 parents ed80803 + 7b58800 commit dc095ca
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 161 deletions.
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "103.0.5060.53",
"chrome:stable": "103.0.5060.53"
"chrome:beta": "104.0.5112.48",
"chrome:stable": "103.0.5060.134"
}
2 changes: 2 additions & 0 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
"viewportWidth": 1000,
"waitForAnimations": true,
"watchForFileChanges": true,
"additionalIgnorePattern": [],
"autoOpen": false,
"browsers": [],
"clientRoute": "/__/",
Expand Down Expand Up @@ -153,6 +154,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
"viewportWidth": 1000,
"waitForAnimations": true,
"watchForFileChanges": true,
"additionalIgnorePattern": [],
"autoOpen": false,
"browsers": [],
"clientRoute": "/__/",
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ const runtimeOptions: Array<RuntimeConfigOption> = [
// having the final config that has the e2e property flattened/compacted
// we may not be able to get the value to ignore.
name: 'additionalIgnorePattern',
defaultValue: (options: Record<string, any> = {}) => options.testingType === 'component' ? defaultSpecPattern.e2e : undefined,
validation: validate.isString,
defaultValue: (options: Record<string, any> = {}) => options.testingType === 'component' ? defaultSpecPattern.e2e : [],
validation: validate.isStringOrArrayOfStrings,
isInternal: true,
canUpdateDuringTestTime: false,
}, {
Expand Down
8 changes: 4 additions & 4 deletions packages/server/__snapshots__/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ exports['Long Dashboard URL'] = `
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.3.0
│ Browser: Electron 99 (headless)
│ Cypress: 1.2.3
│ Browser: FooBrowser 88
│ Specs: 1 found (app.cy.js) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
│ Params: Tag: false, Group: electron-smoke-tests, Parallel: false │
Expand All @@ -341,9 +341,9 @@ exports['Long Dashboard URL'] = `
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ 6ms 1 2 3 4 5 │
│ ✖ XX:XX 1 2 3 4 5 │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) 6ms 1 2 3 4 5
✖ 1 of 1 failed (100%) XX:XX 1 2 3 4 5
───────────────────────────────────────────────────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/project-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface Cfg extends ReceivedCypressOptions {
}
e2e: Partial<Cfg>
component: Partial<Cfg>
additionalIgnorePattern?: string
additionalIgnorePattern?: string | string[]
}

const localCwd = process.cwd()
Expand Down
5 changes: 4 additions & 1 deletion packages/server/test/integration/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Promise = require('bluebird')
const electron = require('electron')
const commitInfo = require('@cypress/commit-info')
const Fixtures = require('@tooling/system-tests')
const { normalizeStdout } = require('@tooling/system-tests/lib/normalizeStdout')
const snapshot = require('snap-shot-it')
const stripAnsi = require('strip-ansi')
const pkg = require('@packages/root')
Expand Down Expand Up @@ -96,7 +97,9 @@ const snapshotConsoleLogs = function (name) {
// so must switch back to original
process.chdir(previousCwd)

return snapshot(name, stripAnsi(args))
const snap = normalizeStdout(stripAnsi(args))

return snapshot(name, snap)
}

function mockEE () {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ResolvedConfigurationOptions = Partial<{
// (eg from plugin, env, default etc...)
// which is used for showing the config in the UI.
export interface FullConfig extends Partial<Cypress.RuntimeConfigOptions & Cypress.ResolvedConfigOptions> {
additionalIgnorePattern?: string
additionalIgnorePattern?: string | string[]
resolved: ResolvedConfigurationOptions
}

Expand Down
151 changes: 151 additions & 0 deletions system-tests/lib/normalizeStdout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import Fixtures from './fixtures'
import _ from 'lodash'

export const e2ePath = Fixtures.projectPath('e2e')

export const DEFAULT_BROWSERS = ['electron', 'chrome', 'firefox']

export const pathUpToProjectName = Fixtures.projectPath('')

export const browserNameVersionRe = /(Browser\:\s+)(Custom |)(Electron|Chrome|Canary|Chromium|Firefox)(\s\d+)(\s\(\w+\))?(\s+)/

const stackTraceLinesRe = /(\n?[^\S\n\r]*).*?(@|\bat\b)(?:.*node:.*|.*\.(js|coffee|ts|html|jsx|tsx))\??(-\d+)?:\d+:\d+[\n\S\s]*?(\n\s*?\n|$)/g
const availableBrowsersRe = /(Available browsers found on your system are:)([\s\S]+)/g
const crossOriginErrorRe = /(Blocked a frame .* from accessing a cross-origin frame.*|Permission denied.*cross-origin object.*)/gm
const whiteSpaceBetweenNewlines = /\n\s+\n/
const retryDuration = /Timed out retrying after (\d+)ms/g
const escapedRetryDuration = /TORA(\d+)/g

export const STDOUT_DURATION_IN_TABLES_RE = /(\s+?)(\d+ms|\d+:\d+:?\d+)/g

const replaceBrowserName = function (str: string, key: string, customBrowserPath: string, browserName: string, version: string, headless: boolean, whitespace: string) {
// get the padding for the existing browser string
const lengthOfExistingBrowserString = _.sum([browserName.length, version.length, _.get(headless, 'length', 0), whitespace.length])

// this ensures we add whitespace so the border is not shifted
return key + customBrowserPath + _.padEnd('FooBrowser 88', lengthOfExistingBrowserString)
}

const replaceDurationSeconds = function (str: string, p1: string, p2: string, p3: string, p4: string) {
// get the padding for the existing duration
const lengthOfExistingDuration = _.sum([(p2 != null ? p2.length : undefined) || 0, p3.length, p4.length])

return p1 + _.padEnd('X seconds', lengthOfExistingDuration)
}

// duration='1589'
const replaceDurationFromReporter = (str: string, p1: string, p2: string, p3: string) => {
return p1 + _.padEnd('X', p2.length, 'X') + p3
}

const replaceNodeVersion = (str: string, p1: string, p2: string, p3: string) => {
// Accounts for paths that break across lines
const p3Length = p3.includes('\n') ? p3.split('\n')[0].length - 1 : p3.length

return _.padEnd(`${p1}X (/foo/bar/node)`, (p1.length + p2.length + p3Length))
}

const replaceCypressVersion = (str: string, p1: string, p2: string) => {
// Cypress: 12.10.10 -> Cypress: 1.2.3 (handling padding)
return _.padEnd(`${p1}1.2.3`, (p1.length + p2.length))
}

// when swapping out the duration, ensure we pad the
// full length of the duration so it doesn't shift content
const replaceDurationInTables = (str: string, p1: string, p2: string) => {
return _.padStart('XX:XX', p1.length + p2.length)
}

// could be (1 second) or (10 seconds)
// need to account for shortest and longest
const replaceParenTime = (str: string, p1: string) => {
return _.padStart('(X second)', p1.length)
}

const replaceScreenshotDims = (str: string, p1: string) => _.padStart('(YxX)', p1.length)

const replaceUploadingResults = function (orig: string, ...rest: string[]) {
const adjustedLength = Math.max(rest.length, 2)
const match = rest.slice(0, adjustedLength - 2)
const results = match[1].split('\n').map((res) => res.replace(/\(\d+\/(\d+)\)/g, '(*/$1)'))
.sort()
.join('\n')
const ret = match[0] + results + match[3]

return ret
}

// 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
export const replaceStackTraceLines = (str: string) => {
return str.replace(stackTraceLinesRe, (match: string, ...parts: string[]) => {
const isFirefoxStack = parts[1] === '@'
let post = parts[4]

if (isFirefoxStack) {
post = post.replace(whiteSpaceBetweenNewlines, '\n')
}

return `\n [stack trace lines]${post}`
})
}

export const normalizeStdout = function (str: string, options: any = {}) {
const { normalizeStdoutAvailableBrowsers } = options

// remove all of the dynamic parts of stdout
// to normalize against what we expected
str = str
// /Users/jane/........../ -> //foo/bar/.projects/
// (Required when paths are printed outside of our own formatting)
.split(pathUpToProjectName).join('/foo/bar/.projects')

// unless normalization is explicitly turned off then
// always normalize the stdout replacing the browser text
if (normalizeStdoutAvailableBrowsers !== false) {
// usually we are not interested in the browsers detected on this particular system
// but some tests might filter / change the list of browsers
// in that case the test should pass "normalizeStdoutAvailableBrowsers: false" as options
str = str.replace(availableBrowsersRe, '$1\n- browser1\n- browser2\n- browser3')
}

str = str
.replace(browserNameVersionRe, replaceBrowserName)
// numbers in parenths
.replace(/\s\(\d+([ms]|ms)\)/g, '')
// escape "Timed out retrying" messages
.replace(retryDuration, 'TORA$1')
// 12:35 -> XX:XX
.replace(STDOUT_DURATION_IN_TABLES_RE, replaceDurationInTables)
// restore "Timed out retrying" messages
.replace(escapedRetryDuration, 'Timed out retrying after $1ms')
.replace(/(coffee|js)-\d{3}/g, '$1-456')
// Cypress: 2.1.0 -> Cypress: 1.2.3
.replace(/(Cypress\:\s+)(\d+\.\d+\.\d+)/g, replaceCypressVersion)
// Node Version: 10.2.3 (Users/jane/node) -> Node Version: X (foo/bar/node)
.replace(/(Node Version\:\s+v)(\d+\.\d+\.\d+)( \((?:.|\n)*?\)\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)
// (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)
// fix "Require stacks" for CI
.replace(/^(\- )(\/.*\/packages\/server\/)(.*)$/gm, '$1$3')
// Different browsers have different cross-origin error messages
.replace(crossOriginErrorRe, '[Cross origin error message]')
// Replaces connection warning since Chrome or Firefox sometimes take longer to connect
.replace(/Still waiting to connect to .+, retrying in 1 second \(attempt .+\/.+\)\n/g, '')

if (options.sanitizeScreenshotDimensions) {
// screenshot dimensions
str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims)
}

return replaceStackTraceLines(str)
}
Loading

3 comments on commit dc095ca

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dc095ca Jul 21, 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/10.4.0/linux-x64/zachw/issue-22525-dc095ca52c5d47356a0cd9cc9a34fa15d9693e68/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dc095ca Jul 21, 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 arm64 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/10.4.0/darwin-arm64/zachw/issue-22525-dc095ca52c5d47356a0cd9cc9a34fa15d9693e68/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dc095ca Jul 21, 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/10.4.0/darwin-x64/zachw/issue-22525-dc095ca52c5d47356a0cd9cc9a34fa15d9693e68/cypress.tgz

Please sign in to comment.