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

Adding the options normalizing step for open API #1447

Merged
merged 6 commits into from
May 15, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/__snapshots__/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ exports['cypress .run resolves with contents of tmp file 1'] = {
"code": 0,
"failingTests": []
}

exports['cypress .open normalizes config object 1'] = {
"config": "pageLoadTime=10000,watchForFileChanges=false"
}
1 change: 1 addition & 0 deletions cli/lib/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const util = require('./util')

const cypressModuleApi = {
open (options = {}) {
options = util.normalizeModuleOptions(options)
return open.start(options)
},

Expand Down
26 changes: 24 additions & 2 deletions cli/test/lib/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ const cypress = require(`${lib}/cypress`)

describe('cypress', function () {
context('.open', function () {
it('calls open#start, passing in options', function () {
beforeEach(function () {
this.sandbox.stub(open, 'start').resolves()
})

const getCallArgs = R.path(['lastCall', 'args', 0])
const getStartArgs = () => {
expect(open.start).to.be.called
return getCallArgs(open.start)
}

it('calls open#start, passing in options', function () {
cypress.open({ foo: 'foo' })
expect(open.start).to.be.calledWith({ foo: 'foo' })
.then(getStartArgs)
.then((args) => {
expect(args.foo).to.equal('foo')
})
})

it('normalizes config object', () => {
const config = {
pageLoadTime: 10000,
watchForFileChanges: false,
}
cypress.open({ config })
.then(getStartArgs)
.then(snapshot)
})
})

Expand Down