diff --git a/package.json b/package.json index 28cd585f12..4323fe45a4 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,11 @@ "compression": "^1.7.4", "connect-history-api-fallback": "^1.6.0", "debug": "^4.1.1", - "del": "^4.1.1", + "del": "^5.0.0", "express": "^4.17.1", "html-entities": "^1.2.1", - "http-proxy-middleware": "0.19.1", - "import-local": "^2.0.0", + "http-proxy-middleware": "^0.19.1", + "import-local": "^3.0.2", "internal-ip": "^4.3.0", "ip": "^1.1.5", "is-absolute-url": "^3.0.3", @@ -62,7 +62,7 @@ "sockjs-client": "1.4.0", "spdy": "^4.0.1", "strip-ansi": "^3.0.1", - "supports-color": "^6.1.0", + "supports-color": "^7.0.0", "url": "^0.11.0", "webpack-dev-middleware": "^3.7.2", "webpack-log": "^2.0.0", @@ -86,7 +86,7 @@ "eslint-config-prettier": "^6.10.0", "eslint-config-webpack": "^1.2.5", "eslint-plugin-import": "^2.20.0", - "execa": "^1.0.0", + "execa": "^2.0.3", "file-loader": "^5.0.2", "html-loader": "^0.5.5", "html-webpack-plugin": "^3.2.0", diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index cebd199931..227ee1f2b6 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -1,3 +1,7 @@ +/** + * @jest-environment node + */ + 'use strict'; const { join, resolve } = require('path'); @@ -16,20 +20,6 @@ const keyPath = resolve(httpsCertificateDirectory, 'server.key'); const certPath = resolve(httpsCertificateDirectory, 'server.crt'); describe('CLI', () => { - it('--progress', (done) => { - testBin('--progress') - .then((output) => { - expect(output.code).toEqual(0); - expect(output.stderr).toContain('0% compiling'); - // should not profile - expect(output.stderr).not.toContain( - 'ms after chunk modules optimization' - ); - done(); - }) - .catch(done); - }); - it('--quiet', async (done) => { const output = await testBin(`--quiet --colors=false --port ${port1}`); expect(output.code).toEqual(0); @@ -42,43 +32,41 @@ describe('CLI', () => { done(); }); + it('--progress', async () => { + const { exitCode, stderr } = await testBin('--progress'); + expect(exitCode).toEqual(0); + expect(stderr.includes('0% compiling')).toBe(true); + // should not profile + expect(output.stderr).not.toContain( + 'ms after chunk modules optimization' + ); + }); + it('--progress --profile', async () => { - const { code, stderr } = await testBin('--progress --profile'); - expect(code).toEqual(0); + const { exitCode, stderr } = await testBin('--progress --profile'); + expect(exitCode).toEqual(0); // should profile expect(stderr.includes('after chunk modules optimization')).toBe(true); }); - it('--bonjour', (done) => { - testBin('--bonjour') - .then((output) => { - expect(output.code).toEqual(0); - expect(output.stdout).toContain('Bonjour'); - done(); - }) - .catch(done); + it('--bonjour', async () => { + const { exitCode, stdout } = await testBin('--bonjour'); + expect(exitCode).toEqual(0); + expect(stdout.includes('Bonjour')).toBe(true); }); - it('--https', (done) => { - testBin('--https') - .then((output) => { - expect(output.code).toEqual(0); - expect(output.stdout).toContain('Project is running at'); - done(); - }) - .catch(done); + it('--https', async () => { + const { exitCode, stdout } = await testBin('--https'); + expect(exitCode).toEqual(0); + expect(stdout.includes('Project is running at')).toBe(true); }); it('--https --cacert --pfx --key --cert --pfx-passphrase', async () => { - const { code, stdout } = await testBin( + const { exitCode, stdout } = await testBin( `--https --cacert ${caPath} --pfx ${pfxPath} --key ${keyPath} --cert ${certPath} --pfx-passphrase webpack-dev-server` - ) - .then((output) => { - expect(output.code).toEqual(0); - expect(output.stdout).toContain('Project is running at'); - done(); - }) - .catch(done); + ); + expect(exitCode).toEqual(0); + expect(stdout.includes('Project is running at')).toBe(true); }); it('--sockPath', async () => { @@ -108,8 +96,8 @@ describe('CLI', () => { // The Unix socket to listen to (instead of a host). it('--socket', async () => { const socketPath = join('.', 'webpack.sock'); - const { code, stdout } = await testBin(`--socket ${socketPath}`); - expect(code).toEqual(0); + const { exitCode, stdout } = await testBin(`--socket ${socketPath}`); + expect(exitCode).toEqual(0); if (process.platform !== 'win32') { expect(stdout.includes(socketPath)).toBe(true); @@ -131,20 +119,16 @@ describe('CLI', () => { .catch(done); }); - it('should accept the promise function of webpack.config.js', (done) => { - testBin( - false, - resolve(__dirname, '../fixtures/promise-config/webpack.config.js') - ) - .then((output) => { - expect(output.code).toEqual(0); - done(); - }) - .catch((err) => { - // for windows - expect(err.stdout).toContain('Compiled successfully.'); - done(); - }); + it('should accept the promise function of webpack.config.js', async () => { + try { + const { exitCode } = await testBin( + false, + resolve(__dirname, '../fixtures/promise-config/webpack.config.js') + ); + expect(exitCode).toEqual(0); + } catch (err) { + expect(err.stdout.includes('Compiled successfully.')).toBe(true); + } }); // TODO: hiroppy