mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
'use strict';
|
|
|
|
// https://github.com/cypress-io/cypress/issues/316
|
|
|
|
var Promise = require('bluebird');
|
|
var tmp = Promise.promisifyAll(require('tmp'));
|
|
|
|
var fs = require('./fs');
|
|
var _open = require('./exec/open');
|
|
var _run = require('./exec/run');
|
|
var util = require('./util');
|
|
|
|
var cypressModuleApi = {
|
|
open: function open() {
|
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
|
return _open.start(options);
|
|
},
|
|
run: function run() {
|
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
|
options = util.normalizeModuleOptions(options);
|
|
|
|
return tmp.fileAsync().then(function (outputPath) {
|
|
options.outputPath = outputPath;
|
|
|
|
return _run.start(options).then(function (failedTests) {
|
|
return fs.readJsonAsync(outputPath, { throws: false }).then(function (output) {
|
|
if (!output) {
|
|
return {
|
|
failures: failedTests,
|
|
message: 'Could not find Cypress test run results'
|
|
};
|
|
}
|
|
return output;
|
|
});
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = cypressModuleApi;
|