Files
cypress/cli/lib/cypress.js
Aftab Khan d8572371cb Adding the options normalizing step for open API (#1447)
* Adding the normalizing step for open API

* Adding tests to ensure normalization happens
2018-05-15 16:39:07 -04:00

42 lines
998 B
JavaScript

// https://github.com/cypress-io/cypress/issues/316
const Promise = require('bluebird')
const tmp = Promise.promisifyAll(require('tmp'))
const fs = require('./fs')
const open = require('./exec/open')
const run = require('./exec/run')
const util = require('./util')
const cypressModuleApi = {
open (options = {}) {
options = util.normalizeModuleOptions(options)
return open.start(options)
},
run (options = {}) {
options = util.normalizeModuleOptions(options)
return tmp.fileAsync()
.then((outputPath) => {
options.outputPath = outputPath
return run.start(options)
.then((failedTests) => {
return fs.readJsonAsync(outputPath, { throws: false })
.then((output) => {
if (!output) {
return {
failures: failedTests,
message: 'Could not find Cypress test run results',
}
}
return output
})
})
})
},
}
module.exports = cypressModuleApi