Commit 1151f331 authored by Hubert SABLONNIERE's avatar Hubert SABLONNIERE

remove "test" scripts and use mocha directly in the gulp task

- we introduce `npm-run` and a helper to call local CLI tools
parent 6643d5de
...@@ -354,7 +354,7 @@ You'll find the documentation for their APIs here: ...@@ -354,7 +354,7 @@ You'll find the documentation for their APIs here:
If you're working on tests or refactoring tested code, you can run the test suite continuously, using: If you're working on tests or refactoring tested code, you can run the test suite continuously, using:
$ yarn run test-watch $ gulp test-watch
This command runs the test suite and coverage report each time you save the test or the code under test. This command runs the test suite and coverage report each time you save the test or the code under test.
......
...@@ -5,6 +5,8 @@ const gulp = require('gulp') ...@@ -5,6 +5,8 @@ const gulp = require('gulp')
const lint = require('./tasks/lint-task') const lint = require('./tasks/lint-task')
const test = require('./tasks/test-task') const test = require('./tasks/test-task')
const testFiles = ['test/**/*-test.js', 'packages/*/test/**/*-test.js']
gulp.task('lint', () => gulp.task('lint', () =>
lint([ lint([
'gulpfile.js', 'gulpfile.js',
...@@ -13,12 +15,8 @@ gulp.task('lint', () => ...@@ -13,12 +15,8 @@ gulp.task('lint', () =>
]) ])
) )
gulp.task('test', ['lint'], () => gulp.task('test', ['lint'], () => test(testFiles))
test(['test/**/*-test.js', 'packages/*/test/**/*-test.js']) gulp.task('test-only', () => test(testFiles))
) gulp.task('test-watch', () => gulp.watch(allFiles, ['test-only']))
gulp.task('test-only', () =>
test(['test/**/*-test.js', 'packages/*/test/**/*-test.js'])
)
gulp.task('default', ['test']) gulp.task('default', ['test'])
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
"node": ">= 7.10.1" "node": ">= 7.10.1"
}, },
"scripts": { "scripts": {
"test": "nyc --reporter=html --reporter=text mocha",
"test-watch": "nodemon --exec 'nyc --reporter=lcov --reporter=text mocha || true'",
"lint": "standard '{lib*,test}/**/*.js' 'packages/*/{lib,test}/**/*.js' | snazzy", "lint": "standard '{lib*,test}/**/*.js' 'packages/*/{lib,test}/**/*.js' | snazzy",
"format": "prettier-standard gulpfile.js '{lib*,tasks,test}/**/*.js' 'packages/*/{lib,test}/**/*.js'" "format": "prettier-standard gulpfile.js '{lib*,tasks,test}/**/*.js' 'packages/*/{lib,test}/**/*.js'"
}, },
...@@ -25,11 +23,9 @@ ...@@ -25,11 +23,9 @@
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-standard": "emgeee/gulp-standard#0f44da222cea1ddc82dab3b776cc729b744a9c7c", "gulp-standard": "emgeee/gulp-standard#0f44da222cea1ddc82dab3b776cc729b744a9c7c",
"gulp-spawn-mocha": "^3.3.1",
"istanbul": "^0.4.5",
"map-stream": "^0.0.7", "map-stream": "^0.0.7",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"nodemon": "^1.12.1", "npm-run": "^4.1.2",
"nyc": "^11.2.1", "nyc": "^11.2.1",
"prettier-standard": "^6.0.0", "prettier-standard": "^6.0.0",
"snazzy": "^7.0.0", "snazzy": "^7.0.0",
......
'use strict'
const PluginError = require('gulp-util').PluginError
const spawn = require('npm-run').spawn
module.exports = function (command, args) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { stdio: 'inherit' })
child.on('close', (code) => {
if (code === 0) {
return resolve()
}
return reject(new PluginError(`run(${command})`, 'Oops!'))
})
})
}
'use strict' 'use strict'
const vfs = require('vinyl-fs') const run = require('./run-command')
const mocha = require('gulp-spawn-mocha')
module.exports = (glob) => module.exports = (files) => {
vfs.src(glob, { read: false }).pipe( return run('nyc', ['--reporter=html', '--reporter=text', 'mocha', ...files])
mocha({ }
R: 'spec',
istanbul: {
report: ['lcov', 'html']
}
})
)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment