mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-03 21:19:44 -06:00
* Added unit test script wrapper. * Removed bin-up to make lint-coffee fail. * Made mocha tests return non-zero value on failure for reporter and runner * Added empty space to test ci failure. * remove extra whitespace * use Promise.delay instead of hand-rolled sleep function * include root-level tests * exit with number of failures
33 lines
846 B
JavaScript
33 lines
846 B
JavaScript
// This file exists because mocha doesn't return non-zero value when there is a failed test.
|
|
// When https://github.com/mochajs/mocha/issues/3893 is fixed, it will be removed.
|
|
|
|
const { spawn } = require('child_process')
|
|
const Promise = require('bluebird')
|
|
|
|
// Test result on console.
|
|
let log = ''
|
|
const proc = spawn(`node`, ['./node_modules/.bin/mocha', 'src/**/*.spec.*'], {})
|
|
|
|
proc.stdout.on('data', (data) => {
|
|
log += data
|
|
})
|
|
|
|
proc.stdout.on('end', async () => {
|
|
await Promise.delay(500)
|
|
|
|
const result = log.match(/\d+ passing.*\n\s*(\d+) failing/)
|
|
const numFailing = result && parseInt(result[1], 10)
|
|
|
|
if (!isNaN(numFailing)) {
|
|
process.exit(numFailing)
|
|
}
|
|
|
|
process.exit(0)
|
|
})
|
|
|
|
// Show result on console.
|
|
spawn(`node`, ['./node_modules/.bin/mocha', '"src/*.spec.*" "src/**/*.spec.*"'], {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
})
|