mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-14 13:20:29 -05:00
- fixes #1264 - fixes #1321 - fixes #1799 - fixes #2689 - fixes #2688 - fixes #2687 - fixes #2686
44 lines
1000 B
JavaScript
44 lines
1000 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
|