From f33347908066da4f89febe886929b4c5f5e838eb Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 16 Oct 2017 03:46:42 -0200 Subject: [PATCH] =?UTF-8?q?[test]=C2=A0Use=20npm=20scripts=20instead=20of?= =?UTF-8?q?=20gulp=20(#3078)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Makefile | 8 ------ gulpfile.js | 69 ----------------------------------------------- package.json | 13 +++------ test/socket.io.js | 31 ++++----------------- 5 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 Makefile delete mode 100644 gulpfile.js diff --git a/.gitignore b/.gitignore index 32d7d3bbd4..7e78cb2147 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules coverage .idea dist +.nyc_output \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 6e494e024f..0000000000 --- a/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -test: - @./node_modules/.bin/gulp test - -test-cov: - @./node_modules/.bin/gulp test-cov - -.PHONY: test diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 82603d026c..0000000000 --- a/gulpfile.js +++ /dev/null @@ -1,69 +0,0 @@ -const gulp = require('gulp'); -const mocha = require('gulp-mocha'); -const babel = require("gulp-babel"); -const istanbul = require('gulp-istanbul'); -const help = require('gulp-task-listing'); -const del = require('del'); - -gulp.task('help', help); - -gulp.task('default', ['transpile']); - -const TRANSPILE_DEST_DIR = './dist'; - -// By default, individual js files are transformed by babel and exported to /dist -gulp.task('transpile', function () { - return gulp.src("lib/*.js") - .pipe(babel({ "presets": ["es2015"] })) - .pipe(gulp.dest(TRANSPILE_DEST_DIR)); -}); - -gulp.task('clean', function () { - return del([TRANSPILE_DEST_DIR]); -}) - -gulp.task('test', ['transpile'], function(){ - return gulp.src('test/socket.io.js', {read: false}) - .pipe(mocha({ - slow: 200, - reporter: 'spec', - bail: true, - timeout: 10000 - })) - .once('error', function (err) { - console.error(err.stack); - process.exit(1); - }) - .once('end', function () { - process.exit(); - }); -}); - -gulp.task('set-compat-node-env', function() { - process.env.TEST_VERSION = 'compat'; -}); - -gulp.task('test-compat', ['set-compat-node-env', 'test']); - -gulp.task('istanbul-pre-test', function () { - return gulp.src(['lib/**/*.js']) - // Covering files - .pipe(istanbul()) - // Force `require` to return covered files - .pipe(istanbul.hookRequire()); -}); - -gulp.task('test-cov', ['istanbul-pre-test'], function(){ - return gulp.src('test/socket.io.js', {read: false}) - .pipe(mocha({ - reporter: 'dot' - })) - .pipe(istanbul.writeReports()) - .once('error', function (err){ - console.error(err.stack); - process.exit(1); - }) - .once('end', function (){ - process.exit(); - }); -}); diff --git a/package.json b/package.json index 0973bbf019..d6a5d1658c 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "url": "git://github.com/socketio/socket.io" }, "scripts": { - "test": "gulp test" + "test": "nyc mocha --reporter spec --slow 200 --bail --timeout 10000 test/socket.io.js" }, "dependencies": { "debug": "~2.6.6", @@ -31,16 +31,9 @@ "socket.io-parser": "~3.1.1" }, "devDependencies": { - "babel-preset-es2015": "^6.24.1", - "del": "^2.2.2", "expect.js": "0.3.1", - "gulp": "^3.9.1", - "gulp-babel": "^6.1.2", - "gulp-istanbul": "^1.1.1", - "gulp-mocha": "^4.3.1", - "gulp-task-listing": "1.0.1", - "istanbul": "^0.4.5", - "mocha": "^3.3.0", + "mocha": "^3.5.3", + "nyc": "^11.2.1", "superagent": "1.6.1", "supertest": "1.1.0" }, diff --git a/test/socket.io.js b/test/socket.io.js index 44d8d1a8f7..f382d503d2 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -1,12 +1,5 @@ -var testVersion = process.env.TEST_VERSION; var http = require('http').Server; -var io; -if (testVersion === 'compat') { - console.log('testing compat version'); - io = require('../dist'); -} else { - io = require('../lib'); -} +var io = require('../lib'); var fs = require('fs'); var join = require('path').join; var exec = require('child_process').exec; @@ -432,18 +425,9 @@ describe('socket.io', function(){ }); describe('namespaces', function(){ - var Socket; - if (testVersion === 'compat') { - Socket = require('../dist/socket'); - } else { - Socket = require('../lib/socket'); - } - var Namespace; - if (testVersion === 'compat') { - Namespace = require('../dist/namespace'); - } else { - Namespace = require('../lib/namespace'); - } + var Socket = require('../lib/socket'); + var Namespace = require('../lib/namespace'); + it('should be accessible through .sockets', function(){ var sio = io(); expect(sio.sockets).to.be.a(Namespace); @@ -2123,12 +2107,7 @@ describe('socket.io', function(){ }); describe('middleware', function(done){ - var Socket; - if (testVersion === 'compat') { - Socket = require('../dist/socket'); - } else { - Socket = require('../lib/socket'); - } + var Socket = require('../lib/socket'); it('should call functions', function(done){ var srv = http();