mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-23 08:50:20 -05:00
feat: add quiet cli arg/module option (#7714)
* Option to disable Cypress the verbose results to stdout --quiet mode to disable the verbose results to stdout but still use specified formatter * Update cli/schema/cypress.schema.json Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com> * Cypress module support for --quiet Cypress module support for --quiet * Apply suggestions from code review Co-authored-by: Zach Bloomquist <github@chary.us> * Address feedback Address feedback, thanks Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com> Co-authored-by: Zach Bloomquist <github@chary.us>
This commit is contained in:
@@ -75,6 +75,7 @@ exports['shows help for run --foo 1'] = `
|
||||
--parallel enables concurrent runs and automatic load balancing of specs across multiple machines or processes
|
||||
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.json.
|
||||
-P, --project <project-path> path to the project
|
||||
-q, --quiet run quietly, using only the configured reporter
|
||||
--record [bool] records the run. sends test results, screenshots and videos to your Cypress Dashboard.
|
||||
-r, --reporter <reporter> runs a specific mocha reporter. pass a path to use a custom reporter. defaults to "spec"
|
||||
-o, --reporter-options <reporter-options> options for the mocha reporter. defaults to "null"
|
||||
|
||||
@@ -109,6 +109,7 @@ const descriptions = {
|
||||
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
|
||||
port: 'runs Cypress on a specific port. overrides any value in cypress.json.',
|
||||
project: 'path to the project',
|
||||
quiet: 'run quietly, using only the configured reporter',
|
||||
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',
|
||||
reporter: 'runs a specific mocha reporter. pass a path to use a custom reporter. defaults to "spec"',
|
||||
reporterOptions: 'options for the mocha reporter. defaults to "null"',
|
||||
@@ -231,6 +232,7 @@ module.exports = {
|
||||
.option('--parallel', text('parallel'))
|
||||
.option('-p, --port <port>', text('port'))
|
||||
.option('-P, --project <project-path>', text('project'))
|
||||
.option('-q, --quiet', text('quiet'))
|
||||
.option('--record [bool]', text('record'), coerceFalse)
|
||||
.option('-r, --reporter <reporter>', text('reporter'))
|
||||
.option('-o, --reporter-options <reporter-options>', text('reporterOptions'))
|
||||
|
||||
@@ -89,6 +89,10 @@ const processRunOptions = (options = {}) => {
|
||||
args.push('--port', options.port)
|
||||
}
|
||||
|
||||
if (options.quiet) {
|
||||
args.push('--quiet')
|
||||
}
|
||||
|
||||
// if record is defined and we're not
|
||||
// already in ci mode, then send it up
|
||||
if (options.record != null && !options.ci) {
|
||||
|
||||
@@ -214,6 +214,7 @@ const parseOpts = (opts) => {
|
||||
'parallel',
|
||||
'port',
|
||||
'project',
|
||||
'quiet',
|
||||
'reporter',
|
||||
'reporterOptions',
|
||||
'record',
|
||||
|
||||
@@ -147,5 +147,17 @@ describe('cypress', function () {
|
||||
expect(args).to.deep.eq(opts)
|
||||
})
|
||||
})
|
||||
|
||||
it('passes quiet: true', () => {
|
||||
const opts = {
|
||||
quiet: true,
|
||||
}
|
||||
|
||||
return cypress.run(opts)
|
||||
.then(getStartArgs)
|
||||
.then((args) => {
|
||||
expect(args).to.deep.eq(opts)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Vendored
+4
@@ -68,6 +68,10 @@ declare module 'cypress' {
|
||||
* Override default port
|
||||
*/
|
||||
port: number
|
||||
/**
|
||||
* Run quietly, using only the configured reporter
|
||||
*/
|
||||
quiet: boolean
|
||||
/**
|
||||
* Whether to record the test run
|
||||
*/
|
||||
|
||||
@@ -523,3 +523,26 @@ exports['e2e stdout / displays assertion errors'] = `
|
||||
|
||||
|
||||
`
|
||||
|
||||
exports['e2e stdout respects quiet mode 1'] = `
|
||||
|
||||
|
||||
stdout_passing_spec
|
||||
file
|
||||
✓ visits file
|
||||
google
|
||||
✓ visits google
|
||||
✓ google2
|
||||
apple
|
||||
✓ apple1
|
||||
✓ visits apple
|
||||
subdomains
|
||||
✓ cypress1
|
||||
✓ visits cypress
|
||||
✓ cypress3
|
||||
|
||||
|
||||
8 passing
|
||||
|
||||
|
||||
`
|
||||
|
||||
@@ -813,7 +813,7 @@ module.exports = {
|
||||
console.log('')
|
||||
},
|
||||
|
||||
async postProcessRecording (name, cname, videoCompression, shouldUploadVideo) {
|
||||
async postProcessRecording (name, cname, videoCompression, shouldUploadVideo, quiet) {
|
||||
debug('ending the video recording %o', { name, videoCompression, shouldUploadVideo })
|
||||
|
||||
// once this ended promises resolves
|
||||
@@ -824,79 +824,83 @@ module.exports = {
|
||||
return
|
||||
}
|
||||
|
||||
console.log('')
|
||||
const postProcessRecordingOutput = (name, videoCompression) => {
|
||||
console.log('')
|
||||
|
||||
terminal.header('Video', {
|
||||
color: ['cyan'],
|
||||
})
|
||||
terminal.header('Video', {
|
||||
color: ['cyan'],
|
||||
})
|
||||
|
||||
console.log('')
|
||||
console.log('')
|
||||
|
||||
const table = terminal.table({
|
||||
colWidths: [3, 21, 76],
|
||||
colAligns: ['left', 'left', 'left'],
|
||||
type: 'noBorder',
|
||||
style: {
|
||||
'padding-right': 0,
|
||||
},
|
||||
chars: {
|
||||
'left': ' ',
|
||||
'right': '',
|
||||
},
|
||||
})
|
||||
const table = terminal.table({
|
||||
colWidths: [3, 21, 76],
|
||||
colAligns: ['left', 'left', 'left'],
|
||||
type: 'noBorder',
|
||||
style: {
|
||||
'padding-right': 0,
|
||||
},
|
||||
chars: {
|
||||
'left': ' ',
|
||||
'right': '',
|
||||
},
|
||||
})
|
||||
|
||||
table.push([
|
||||
gray('-'),
|
||||
gray('Started processing:'),
|
||||
chalk.cyan(`Compressing to ${videoCompression} CRF`),
|
||||
])
|
||||
table.push([
|
||||
gray('-'),
|
||||
gray('Started processing:'),
|
||||
chalk.cyan(`Compressing to ${videoCompression} CRF`),
|
||||
])
|
||||
|
||||
console.log(table.toString())
|
||||
console.log(table.toString())
|
||||
|
||||
const started = Date.now()
|
||||
let progress = Date.now()
|
||||
const throttle = env.get('VIDEO_COMPRESSION_THROTTLE') || human('10 seconds')
|
||||
const started = Date.now()
|
||||
let progress = Date.now()
|
||||
const throttle = env.get('VIDEO_COMPRESSION_THROTTLE') || human('10 seconds')
|
||||
|
||||
const onProgress = function (float) {
|
||||
if (float === 1) {
|
||||
const finished = Date.now() - started
|
||||
const dur = `(${humanTime.long(finished)})`
|
||||
return function (float) {
|
||||
if (float === 1) {
|
||||
const finished = Date.now() - started
|
||||
const dur = `(${humanTime.long(finished)})`
|
||||
|
||||
const table = terminal.table({
|
||||
colWidths: [3, 21, 61, 15],
|
||||
colAligns: ['left', 'left', 'left', 'right'],
|
||||
type: 'noBorder',
|
||||
style: {
|
||||
'padding-right': 0,
|
||||
},
|
||||
chars: {
|
||||
'left': ' ',
|
||||
'right': '',
|
||||
},
|
||||
})
|
||||
const table = terminal.table({
|
||||
colWidths: [3, 21, 61, 15],
|
||||
colAligns: ['left', 'left', 'left', 'right'],
|
||||
type: 'noBorder',
|
||||
style: {
|
||||
'padding-right': 0,
|
||||
},
|
||||
chars: {
|
||||
'left': ' ',
|
||||
'right': '',
|
||||
},
|
||||
})
|
||||
|
||||
table.push([
|
||||
gray('-'),
|
||||
gray('Finished processing:'),
|
||||
`${formatPath(name, getWidth(table, 2), 'cyan')}`,
|
||||
gray(dur),
|
||||
])
|
||||
table.push([
|
||||
gray('-'),
|
||||
gray('Finished processing:'),
|
||||
`${formatPath(name, getWidth(table, 2), 'cyan')}`,
|
||||
gray(dur),
|
||||
])
|
||||
|
||||
console.log(table.toString())
|
||||
console.log(table.toString())
|
||||
|
||||
console.log('')
|
||||
}
|
||||
console.log('')
|
||||
}
|
||||
|
||||
if (Date.now() - progress > throttle) {
|
||||
// bump up the progress so we dont
|
||||
// continuously get notifications
|
||||
progress += throttle
|
||||
const percentage = `${Math.ceil(float * 100)}%`
|
||||
if (Date.now() - progress > throttle) {
|
||||
// bump up the progress so we dont
|
||||
// continuously get notifications
|
||||
progress += throttle
|
||||
const percentage = `${Math.ceil(float * 100)}%`
|
||||
|
||||
console.log(' Compression progress: ', chalk.cyan(percentage))
|
||||
console.log(' Compression progress: ', chalk.cyan(percentage))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onProgress = quiet ? undefined : postProcessRecordingOutput(name, videoCompression)
|
||||
|
||||
return videoCapture.process(name, cname, videoCompression, onProgress)
|
||||
},
|
||||
|
||||
@@ -1061,7 +1065,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
waitForTestsToFinishRunning (options = {}) {
|
||||
const { project, screenshots, startedVideoCapture, endVideoCapture, videoName, compressedVideoName, videoCompression, videoUploadOnPasses, exit, spec, estimated } = options
|
||||
const { project, screenshots, startedVideoCapture, endVideoCapture, videoName, compressedVideoName, videoCompression, videoUploadOnPasses, exit, spec, estimated, quiet } = options
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/2370
|
||||
// delay 1 second if we're recording a video to give
|
||||
@@ -1095,10 +1099,11 @@ module.exports = {
|
||||
return obj
|
||||
}
|
||||
|
||||
this.displayResults(obj, estimated)
|
||||
|
||||
if (screenshots && screenshots.length) {
|
||||
this.displayScreenshots(screenshots)
|
||||
if (!quiet) {
|
||||
this.displayResults(obj, estimated)
|
||||
if (screenshots && screenshots.length) {
|
||||
this.displayScreenshots(screenshots)
|
||||
}
|
||||
}
|
||||
|
||||
const { tests, stats } = obj
|
||||
@@ -1137,6 +1142,7 @@ module.exports = {
|
||||
compressedVideoName,
|
||||
videoCompression,
|
||||
suv,
|
||||
quiet,
|
||||
)
|
||||
.catch(warnVideoRecordingFailed)
|
||||
}
|
||||
@@ -1191,19 +1197,23 @@ module.exports = {
|
||||
config,
|
||||
}
|
||||
|
||||
displayRunStarting({
|
||||
config,
|
||||
specs,
|
||||
group,
|
||||
tag,
|
||||
runUrl,
|
||||
browser,
|
||||
parallel,
|
||||
specPattern,
|
||||
})
|
||||
if (!options.quiet) {
|
||||
displayRunStarting({
|
||||
config,
|
||||
specs,
|
||||
group,
|
||||
tag,
|
||||
runUrl,
|
||||
browser,
|
||||
parallel,
|
||||
specPattern,
|
||||
})
|
||||
}
|
||||
|
||||
const runEachSpec = (spec, index, length, estimated) => {
|
||||
displaySpecHeader(spec.name, index + 1, length, estimated)
|
||||
if (!options.quiet) {
|
||||
displaySpecHeader(spec.name, index + 1, length, estimated)
|
||||
}
|
||||
|
||||
return this.runSpec(spec, options, estimated)
|
||||
.get('results')
|
||||
@@ -1282,6 +1292,7 @@ module.exports = {
|
||||
exit: options.exit,
|
||||
videoCompression: options.videoCompression,
|
||||
videoUploadOnPasses: options.videoUploadOnPasses,
|
||||
quiet: options.quiet,
|
||||
}),
|
||||
|
||||
connection: this.waitForBrowserToConnect({
|
||||
@@ -1322,6 +1333,7 @@ module.exports = {
|
||||
_.defaults(options, {
|
||||
isTextTerminal: true,
|
||||
browser: 'electron',
|
||||
quiet: false,
|
||||
})
|
||||
|
||||
const socketId = random.id()
|
||||
@@ -1410,9 +1422,14 @@ module.exports = {
|
||||
videoUploadOnPasses: config.videoUploadOnPasses,
|
||||
exit: options.exit,
|
||||
headed: options.headed,
|
||||
quiet: options.quiet,
|
||||
outputPath: options.outputPath,
|
||||
})
|
||||
.tap(renderSummaryTable(runUrl))
|
||||
.tap((runSpecs) => {
|
||||
if (!options.quiet) {
|
||||
renderSummaryTable(runUrl)(runSpecs)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (record) {
|
||||
|
||||
@@ -13,7 +13,7 @@ const nestedObjectsInCurlyBracesRe = /\{(.+?)\}/g
|
||||
const nestedArraysInSquareBracketsRe = /\[(.+?)\]/g
|
||||
const everythingAfterFirstEqualRe = /=(.*)/
|
||||
|
||||
const whitelist = 'appPath apiKey browser ci ciBuildId clearLogs config configFile cwd env execPath exit exitWithCode generateKey getKey group headed inspectBrk key logs mode outputPath parallel ping port project proxySource record reporter reporterOptions returnPkg runMode runProject smokeTest spec tag updating version'.split(' ')
|
||||
const whitelist = 'appPath apiKey browser ci ciBuildId clearLogs config configFile cwd env execPath exit exitWithCode generateKey getKey group headed inspectBrk key logs mode outputPath parallel ping port project proxySource quiet record reporter reporterOptions returnPkg runMode runProject smokeTest spec tag updating version'.split(' ')
|
||||
// returns true if the given string has double quote character "
|
||||
// only at the last position.
|
||||
const hasStrayEndQuote = (s) => {
|
||||
|
||||
@@ -28,6 +28,15 @@ describe('e2e stdout', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('respects quiet mode', function () {
|
||||
return e2e.exec(this, {
|
||||
spec: 'stdout_passing_spec.coffee',
|
||||
timeout: 120000,
|
||||
snapshot: true,
|
||||
quiet: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('displays fullname of nested specfile', function () {
|
||||
return e2e.exec(this, {
|
||||
port: 2020,
|
||||
|
||||
@@ -509,6 +509,10 @@ const e2e = {
|
||||
args.push('--record')
|
||||
}
|
||||
|
||||
if (options.quiet) {
|
||||
args.push('--quiet')
|
||||
}
|
||||
|
||||
if (options.parallel) {
|
||||
args.push('--parallel')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user