Skip to content
Permalink
Browse files

test: don't use --runInBand and improve execution performance (#2007)

backport from #2005 to master branch
  • Loading branch information
hiroppy committed Jun 10, 2019
1 parent 2b4cb52 commit 4dec6b27b5f83f29899979528d565dff09040600
Showing with 395 additions and 168 deletions.
  1. +6 −1 .babelrc
  2. +32 −0 globalSetupTest.js
  3. +1 −0 jest.config.js
  4. +75 −30 package-lock.json
  5. +3 −1 package.json
  6. +4 −2 test/cli/cli.test.js
  7. +3 −2 test/client/clients/SockJSClient.test.js
  8. +7 −6 test/e2e/Client.test.js
  9. +43 −35 test/e2e/ClientOptions.test.js
  10. +2 −1 test/integration/MultiCompiler.test.js
  11. +2 −1 test/integration/UniversalCompiler.test.js
  12. +51 −0 test/ports-map.js
  13. +7 −4 test/server/Server.test.js
  14. +2 −2 test/server/__snapshots__/Server.test.js.snap
  15. +2 −0 test/server/after-option.test.js
  16. +2 −0 test/server/before-option.test.js
  17. +4 −1 test/server/compress-option.test.js
  18. +10 −0 test/server/contentBase-option.test.js
  19. +3 −0 test/server/headers-option.test.js
  20. +7 −0 test/server/historyApiFallback-option.test.js
  21. +13 −7 test/server/host-option.test.js
  22. +7 −6 test/server/hot-option.test.js
  23. +3 −2 test/server/hotOnly-option.test.js
  24. +5 −1 test/server/http2-option.test.js
  25. +7 −2 test/server/https-option.test.js
  26. +11 −12 test/server/inline-option.test.js
  27. +3 −0 test/server/lazy-option.test.js
  28. +3 −0 test/server/liveReload-option.test.js
  29. +4 −0 test/server/mimeTypes-option.test.js
  30. +2 −0 test/server/onListening-option.test.js
  31. +8 −6 test/server/open-option.test.js
  32. +2 −1 test/server/port-option.test.js
  33. +19 −14 test/server/proxy-option.test.js
  34. +9 −3 test/server/serverMode-option.test.js
  35. +3 −2 test/server/servers/SockJSServer.test.js
  36. +5 −3 test/server/sockPath-option.test.js
  37. +5 −3 test/server/stats-option.test.js
  38. +18 −19 test/server/utils/createDomain.test.js
  39. +2 −1 test/server/utils/routes.test.js
@@ -1,3 +1,8 @@
{
"presets": ["@babel/preset-env"]
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}
@@ -0,0 +1,32 @@
'use strict';

// eslint-disable-next-line import/no-extraneous-dependencies
const tcpPortUsed = require('tcp-port-used');
const ports = require('./test/ports-map');

async function validatePorts() {
const samples = [];

Object.keys(ports).forEach((key) => {
const value = ports[key];
const arr = Array.isArray(value) ? value : [value];

arr.forEach((port) => {
const check = tcpPortUsed.check(port, 'localhost').then((inUse) => {
if (inUse) throw new Error(`${port} has already used. [${key}]`);
});

samples.push(check);
});
});

try {
await Promise.all(samples);
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
process.exit(1);
}
}

module.exports = validatePorts;
@@ -7,4 +7,5 @@ module.exports = {
moduleFileExtensions: ['js', 'json'],
testMatch: ['**/test/**/*.test.js'],
setupFilesAfterEnv: ['<rootDir>/setupTest.js'],
globalSetup: '<rootDir>/globalSetupTest.js',
};

Some generated files are not rendered by default. Learn more.

@@ -19,7 +19,7 @@
"lint": "npm-run-all -l -p \"lint:**\"",
"commitlint": "commitlint --from=master",
"security": "npm audit",
"test:only": "jest --runInBand",
"test:only": "jest",
"test:coverage": "npm run test:only -- --coverage",
"test:watch": "npm run test:coverage --watch",
"test": "npm run test:coverage",
@@ -70,6 +70,7 @@
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@commitlint/cli": "^7.6.1",
"@commitlint/config-conventional": "^7.6.0",
@@ -102,6 +103,7 @@
"standard-version": "^6.0.1",
"style-loader": "^0.23.1",
"supertest": "^4.0.2",
"tcp-port-used": "^1.0.1",
"url-loader": "^1.1.2",
"webpack": "^4.33.0",
"webpack-cli": "^3.3.3",
@@ -162,8 +162,10 @@ describe('CLI', () => {
const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js');
const examplePath = resolve(__dirname, '../../examples/cli/public');

const cp = execa('node', [cliPath], { cwd: examplePath });
const cp2 = execa('node', [cliPath], { cwd: examplePath });
const cp = execa('node', [cliPath, '--colors=false'], { cwd: examplePath });
const cp2 = execa('node', [cliPath, '--colors=false'], {
cwd: examplePath,
});

const runtime = {
cp: {
@@ -4,6 +4,7 @@ const http = require('http');
const express = require('express');
const sockjs = require('sockjs');
const SockJSClient = require('../../../client-src/clients/SockJSClient');
const port = require('../../ports-map').sockJSClient;

describe('SockJSClient', () => {
let socketServer;
@@ -14,7 +15,7 @@ describe('SockJSClient', () => {
const app = new express();

listeningApp = http.createServer(app);
listeningApp.listen(8080, 'localhost', () => {
listeningApp.listen(port, 'localhost', () => {
socketServer = sockjs.createServer();
socketServer.installHandlers(listeningApp, {
prefix: '/sockjs-node',
@@ -33,7 +34,7 @@ describe('SockJSClient', () => {
}, 1000);
});

const client = new SockJSClient('http://localhost:8080/sockjs-node');
const client = new SockJSClient(`http://localhost:${port}/sockjs-node`);
const data = [];

client.onOpen(() => {

0 comments on commit 4dec6b2

Please sign in to comment.