From 5df9808d4c4ca2d0088c08d8aee84ad5a5f3da3c Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 13 Apr 2018 10:41:12 -0700 Subject: [PATCH] Remove launch.json in favor of auto attach debugging --- .vscode/launch.json | 23 ----------------------- gulpfile.js | 27 +++++++++++++++++---------- package.json | 2 ++ 3 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 064f0f5e..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Mocha Tests", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/mocha", - "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/mocha.cmd" - }, - "runtimeArgs": [ - "--colors", - "--recursive", - "${workspaceRoot}/lib" - ], - "sourceMaps": true, - "outFiles": [ "${workspaceRoot}/lib/**/*.js" ], - "internalConsoleOptions": "openOnSessionStart" - } - ] -} diff --git a/gulpfile.js b/gulpfile.js index af4fdce0..f3a23e80 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,6 +25,13 @@ let outDir = tsProject.config.compilerOptions.outDir; const addons = fs.readdirSync(`${__dirname}/src/addons`); +const TEST_PATHS = [ + `${outDir}/*test.js`, + `${outDir}/**/*test.js`, + `${outDir}/*integration.js`, + `${outDir}/**/*integration.js` +]; + // Under some environments like TravisCI, this comes out at absolute which can // break the build. This ensures that the outDir is absolute. if (path.normalize(outDir).indexOf(__dirname) !== 0) { @@ -142,13 +149,14 @@ gulp.task('instrument-test', function () { .pipe(istanbul.hookRequire()); }); -gulp.task('mocha', ['instrument-test'], function () { - return gulp.src([ - `${outDir}/*test.js`, - `${outDir}/**/*test.js`, - `${outDir}/*integration.js`, - `${outDir}/**/*integration.js` - ], {read: false}) +gulp.task('mocha', function () { + return gulp.src(TEST_PATHS, {read: false}) + .pipe(mocha()) + .once('error', () => process.exit(1)); +}); + +gulp.task('mocha-coverage', ['instrument-test'], function () { + return gulp.src(TEST_PATHS, {read: false}) .pipe(mocha()) .once('error', () => process.exit(1)) .pipe(istanbul.writeReports()); @@ -158,13 +166,12 @@ gulp.task('mocha', ['instrument-test'], function () { * Run single test file by file name(without file extension). Example of the command: * gulp mocha-test --test InputHandler.test */ -gulp.task('mocha-test', ['instrument-test'], function () { +gulp.task('mocha-test', [], function () { let testName = util.env.test; util.log("Run test by Name: " + testName); return gulp.src([`${outDir}/${testName}.js`, `${outDir}/**/${testName}.js`], {read: false}) .pipe(mocha()) - .once('error', () => process.exit(1)) - .pipe(istanbul.writeReports()); + .once('error', () => process.exit(1)); }); /** diff --git a/package.json b/package.json index 0b1f8cc7..bfcb0e26 100644 --- a/package.json +++ b/package.json @@ -79,11 +79,13 @@ "start-zmodem": "node demo/zmodem/app", "lint": "tslint src/*.ts src/**/*.ts", "test": "npm-run-all mocha lint", + "test-debug": "node --inspect-brk node_modules/.bin/gulp test", "mocha": "gulp test", "build:docs": "jsdoc -c jsdoc.json", "tsc": "tsc", "build": "gulp build", "prepublish": "npm run build", + "coverage": "gulp mocha-coverage", "coveralls": "gulp coveralls", "webpack": "gulp webpack", "watch": "gulp watch"