fixes #657, accept --headed option, remove undocumented --show-headless-gui

This commit is contained in:
Brian Mann
2017-09-17 14:56:50 -04:00
parent 5a78ef65fa
commit f2591f81b3
8 changed files with 30 additions and 16 deletions
+3 -1
View File
@@ -12,7 +12,7 @@ const coerceFalse = (arg) => {
const parseOpts = (opts) => _.pick(opts,
'project', 'spec', 'reporter', 'reporterOptions', 'path', 'destination',
'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser', 'detached')
'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser', 'detached', 'headed')
const descriptions = {
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',
@@ -30,6 +30,7 @@ const descriptions = {
detached: 'runs Cypress application in detached mode',
project: 'path to the project',
version: 'Prints Cypress version',
headed: 'displays the Electron browser instead of running headlessly',
}
const knownCommands = ['version', 'run', 'open', 'install', 'verify', '-v', '--version', 'help', '-h', '--help']
@@ -80,6 +81,7 @@ module.exports = {
.usage('[options]')
.description('Runs Cypress tests from the CLI without the GUI')
.option('--record [bool]', text('record'), coerceFalse)
.option('--headed', text('headed'))
.option('-k, --key <record-key>', text('key'))
.option('-s, --spec <spec>', text('spec'))
.option('-r, --reporter <reporter>', text('reporter'))
+4
View File
@@ -65,6 +65,10 @@ const processRunOptions = (options = {}) => {
args.push('--browser', options.browser)
}
if (options.headed) {
args.push('--headed', options.headed)
}
return args
}
+5
View File
@@ -153,6 +153,11 @@ describe('cli', function () {
this.exec('run --project /tmp/foo/bar')
expect(run.start).to.be.calledWith({ project: '/tmp/foo/bar' })
})
it('calls run with heded', function () {
this.exec('run --headed')
expect(run.start).to.be.calledWith({ headed: true })
})
})
it('open calls open.start with options', function () {
+9
View File
@@ -78,6 +78,15 @@ describe('exec run', function () {
})
})
it('spawns with --headed true', function () {
return run.start({ headed: true })
.then(() => {
expect(spawn.start).to.be.calledWith([
'--run-project', process.cwd(), '--headed', true,
])
})
})
it('spawns with --output-path', function () {
return run.start({ outputPath: '/path/to/output' })
.then(() => {
+4 -5
View File
@@ -98,10 +98,9 @@ module.exports = {
getElectronProps: (showGui, project, write) ->
obj = {
width: 1280
height: 720
show: showGui
devTools: showGui
width: 1280
height: 720
show: showGui
onCrashed: ->
err = errors.get("RENDERER_CRASHED")
errors.log(err)
@@ -508,7 +507,7 @@ module.exports = {
videoRecording: config.videoRecording
videoCompression: config.videoCompression
spec: options.spec
gui: options.showHeadlessGui
gui: options.headed
browser: options.browser
outputPath: options.outputPath
})
+1 -2
View File
@@ -5,7 +5,7 @@ coerce = require("./coerce")
config = require("../config")
cwd = require("../cwd")
whitelist = "appPath execPath apiKey smokeTest getKey generateKey runProject project spec ci record updating ping key logs clearLogs returnPkg version mode autoOpen removeIds showHeadlessGui config exitWithCode hosts browser headless outputPath group groupId".split(" ")
whitelist = "appPath execPath apiKey smokeTest getKey generateKey runProject project spec ci record updating ping key logs clearLogs returnPkg version mode autoOpen removeIds headed config exitWithCode hosts browser headless outputPath group groupId".split(" ")
whitelist = whitelist.concat(config.getConfigKeys())
parseNestedValues = (vals) ->
@@ -46,7 +46,6 @@ module.exports = {
"auto-open": "autoOpen"
"env": "environmentVariables"
"headless": "isTextTerminal"
"show-headless-gui":"showHeadlessGui"
"exit-with-code": "exitWithCode"
"reporter-options": "reporterOptions"
"output-path": "outputPath"
@@ -423,7 +423,7 @@ describe "lib/cypress", ->
expect(bundle._watching).to.be.true
it "runs project headlessly and displays gui", ->
cypress.start(["--run-project=#{@todosPath}", "--show-headless-gui"])
cypress.start(["--run-project=#{@todosPath}", "--headed"])
.then =>
expect(browsers.open).to.be.calledWithMatch("electron", {
url: "http://localhost:8888/__/#/tests/__all"
@@ -57,16 +57,12 @@ describe "lib/modes/headless", ->
expect(props.width).to.eq(1280)
expect(props.height).to.eq(720)
it "sets show and devTools to boolean", ->
it "sets show to boolean", ->
props = headless.getElectronProps(false)
expect(props.show).to.be.false
expect(props.devTools).to.be.false
props = headless.getElectronProps(true)
expect(props.show).to.be.true
expect(props.devTools).to.be.true
it "sets recordFrameRate and onPaint when write is true", ->
write = @sandbox.stub()
@@ -437,7 +433,7 @@ describe "lib/modes/headless", ->
project: @projectInstance
})
it "passes showHeadlessGui to openProject.launch", ->
headless.run({showHeadlessGui: true})
it "passes headed to openProject.launch", ->
headless.run({headed: true})
.then ->
expect(openProject.launch).to.be.calledWithMatch("electron", undefined, {show: true})