-
-
Save rowellx68/ea57bbbcd1ed416bcef8cf55fb1cfd98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gulp = require("gulp"); | |
const { spawn } = require("child_process"); | |
const cypress = require("../gulp-cypress"); | |
// hold onto the server process | |
let server; | |
function startServer(done) { | |
server = spawn(process.argv[0], ["au", "watch", "---env", "stage"], { | |
detached: true, | |
stdio: "ignore" | |
}); | |
server.unref(); | |
done(); | |
} | |
function runCypress(done) { | |
const spec = "test/cypress/integration/**/*.spec.ts"; | |
return gulp | |
.src("/") | |
.pipe(cypress({spec})) | |
.on("error", error => handleError(error, done)) | |
.on("end", () => killServer(done)); | |
} | |
function killServer(done) { | |
server.kill(); | |
done(); | |
} | |
function handleError(error, done) { | |
server.kill(); | |
done(error); | |
} | |
const runTests = gulp.series(startServer, runCypress, killServer); | |
module.exports = { | |
run: runTests | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const es = require("event-stream"); | |
const cypress = require("cypress"); | |
module.exports = function (options) { | |
// change as required | |
const defaults = { | |
reporter: "mocha-teamcity-reporter", | |
browser: "chrome" | |
}; | |
options = Object.assign(defaults, options || {}); | |
return es.through(() => { }, function () { | |
const stream = this; | |
cypress.run(options) | |
.then(() => { | |
stream.emit("end"); | |
}) | |
.catch(() => { | |
stream.emit("error"); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment