Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): Fix 5.0 spec duration always reporting as 0ms #8313

Merged
merged 3 commits into from Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server/lib/modes/run.js
Expand Up @@ -1295,7 +1295,7 @@ module.exports = {
})),
})

return writeOutput(outputPath, moduleAPIResults).return(moduleAPIResults)
return writeOutput(outputPath, moduleAPIResults).return(results)
})
},

Expand Down
13 changes: 9 additions & 4 deletions packages/server/test/e2e/5_spec_isolation_spec.js
@@ -1,13 +1,14 @@
// TODO: rename this file to 5_module_api_spec

const path = require('path')
const _ = require('lodash')
const snapshot = require('snap-shot-it')
const fs = require('../../lib/util/fs')
const e2e = require('../support/helpers/e2e').default
const { default: e2e, STDOUT_DURATION_IN_TABLES_RE } = require('../support/helpers/e2e')
const Fixtures = require('../support/helpers/fixtures')
const { expectCorrectModuleApiResult } = require('../support/helpers/resultsUtils')
const e2ePath = Fixtures.projectPath('e2e')
const it = e2e.it
const { it } = e2e

const outputPath = path.join(e2ePath, 'output.json')

Expand All @@ -26,8 +27,12 @@ describe('e2e spec_isolation', () => {
outputPath,
snapshot: false,
expectedExitCode: 5,
async onRun (exec) {
await exec()
async onRun (execFn) {
const { stdout } = await execFn()

_.each(STDOUT_DURATION_IN_TABLES_RE.exec(stdout), (str) => {
expect(str.trim(), 'spec durations in tables should not be 0ms').not.eq('0ms')
})

// now what we want to do is read in the outputPath
// and snapshot it so its what we expect after normalizing it
Expand Down
4 changes: 3 additions & 1 deletion packages/server/test/support/helpers/e2e.ts
Expand Up @@ -44,6 +44,8 @@ const availableBrowsersRe = /(Available browsers found on your system are:)([\s\
const crossOriginErrorRe = /(Blocked a frame .* from accessing a cross-origin frame.*|Permission denied.*cross-origin object.*)/gm
const whiteSpaceBetweenNewlines = /\n\s+\n/

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

// 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
Expand Down Expand Up @@ -153,7 +155,7 @@ const normalizeStdout = function (str, options: any = {}) {
// numbers in parenths
.replace(/\s\(\d+([ms]|ms)\)/g, '')
// 12:35 -> XX:XX
.replace(/(\s+?)(\d+ms|\d+:\d+:?\d+)/g, replaceDurationInTables)
.replace(STDOUT_DURATION_IN_TABLES_RE, replaceDurationInTables)
.replace(/(coffee|js)-\d{3}/g, '$1-456')
// Cypress: 2.1.0 -> Cypress: 1.2.3
.replace(/(Cypress\:\s+)(\d+\.\d+\.\d+)/g, replaceCypressVersion)
Expand Down