diff --git a/client-src/clients/BaseClient.js b/client-src/clients/BaseClient.js index 1dfa65911b..7c47b70e2a 100644 --- a/client-src/clients/BaseClient.js +++ b/client-src/clients/BaseClient.js @@ -1,5 +1,3 @@ -'use strict'; - /* eslint-disable no-unused-vars */ diff --git a/client-src/clients/SockJSClient.js b/client-src/clients/SockJSClient.js index 388c25fef1..5824bc9af9 100644 --- a/client-src/clients/SockJSClient.js +++ b/client-src/clients/SockJSClient.js @@ -1,5 +1,3 @@ -'use strict'; - /* eslint-disable no-unused-vars */ diff --git a/client-src/clients/WebsocketClient.js b/client-src/clients/WebsocketClient.js index 1ae8ecf2fb..6b4e5acf91 100644 --- a/client-src/clients/WebsocketClient.js +++ b/client-src/clients/WebsocketClient.js @@ -1,5 +1,3 @@ -'use strict'; - const BaseClient = require('./BaseClient'); module.exports = class WebsocketClient extends BaseClient {}; diff --git a/test/__snapshots__/Server.test.js.snap b/test/__snapshots__/Server.test.js.snap new file mode 100644 index 0000000000..afd2139df5 --- /dev/null +++ b/test/__snapshots__/Server.test.js.snap @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Server addEntries add hot option 1`] = ` +Array [ + Array [ + "client", + "index.js?http:", + "localhost", + ], + Array [ + "node_modules", + "webpack", + "hot", + "dev-server.js", + ], + Array [ + "foo.js", + ], +] +`; + +exports[`Server addEntries add hot option 2`] = ` +Array [ + HotModuleReplacementPlugin { + "fullBuildTimeout": 200, + "multiStep": undefined, + "options": Object {}, + "requestTimeout": 10000, + }, +] +`; + +exports[`Server addEntries add hotOnly option 1`] = ` +Array [ + Array [ + "client", + "index.js?http:", + "localhost", + ], + Array [ + "node_modules", + "webpack", + "hot", + "only-dev-server.js", + ], + Array [ + "foo.js", + ], +] +`; + +exports[`Server addEntries add hotOnly option 2`] = ` +Array [ + HotModuleReplacementPlugin { + "fullBuildTimeout": 200, + "multiStep": undefined, + "options": Object {}, + "requestTimeout": 10000, + }, +] +`; + +exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 1`] = ` +Array [ + "errors", + "warnings", + "hash", + "assetsByChunkName", + "assets", + "filteredAssets", +] +`; + +exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 2`] = ` +Array [ + "errors", + "warnings", + "hash", + "assetsByChunkName", + "assets", + "filteredAssets", +] +`; + +exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 3`] = ` +Array [ + "errors", + "warnings", + "hash", + "assetsByChunkName", + "assets", + "filteredAssets", +] +`; + +exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 4`] = ` +Array [ + "errors", + "warnings", + "hash", + "assetsByChunkName", + "assets", + "filteredAssets", +] +`; + +exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 5`] = ` +Array [ + "errors", + "warnings", + "hash", + "assetsByChunkName", + "assets", + "filteredAssets", +] +`; diff --git a/test/client/utils/createSocketUrl.test.js b/test/client/utils/createSocketUrl.test.js index 172ec6007f..b521242c76 100644 --- a/test/client/utils/createSocketUrl.test.js +++ b/test/client/utils/createSocketUrl.test.js @@ -24,7 +24,7 @@ describe('createSocketUrl', () => { const { default: createSocketUrl, // eslint-disable-next-line global-require - } = require('../../../../client-src/default/utils/createSocketUrl'); + } = require('../../../client-src/default/utils/createSocketUrl'); test(`should return the url when __resourceQuery is ${url}`, () => { expect(createSocketUrl(url)).toMatchSnapshot(); diff --git a/test/client/utils/getCurrentScriptSource.test.js b/test/client/utils/getCurrentScriptSource.test.js index e7ec05aceb..b6c4f4d017 100644 --- a/test/client/utils/getCurrentScriptSource.test.js +++ b/test/client/utils/getCurrentScriptSource.test.js @@ -2,7 +2,7 @@ const { default: getCurrentScriptSource, -} = require('../../../../client-src/default/utils/getCurrentScriptSource'); +} = require('../../../client-src/default/utils/getCurrentScriptSource'); describe('getCurrentScriptSource', () => { afterEach(() => { diff --git a/test/client/utils/reloadApp.test.js b/test/client/utils/reloadApp.test.js index be679dace4..9686dddf70 100644 --- a/test/client/utils/reloadApp.test.js +++ b/test/client/utils/reloadApp.test.js @@ -25,8 +25,7 @@ describe('reloadApp', () => { }); // eslint-disable-next-line global-require - reloadApp = require('../../../../client-src/default/utils/reloadApp') - .default; + reloadApp = require('../../../client-src/default/utils/reloadApp').default; }); afterEach(() => { diff --git a/test/client/utils/sendMessage.test.js b/test/client/utils/sendMessage.test.js index fd8ecbd315..17cbb4ea61 100644 --- a/test/client/utils/sendMessage.test.js +++ b/test/client/utils/sendMessage.test.js @@ -4,7 +4,7 @@ const { default: sendMessage, -} = require('../../../../client-src/default/utils/sendMessage'); +} = require('../../../client-src/default/utils/sendMessage'); describe('sendMessage', () => { afterEach(() => { diff --git a/test/server/open-option.test.js b/test/server/open-option.test.js index c0f1768b99..1dae3cba70 100644 --- a/test/server/open-option.test.js +++ b/test/server/open-option.test.js @@ -1,13 +1,13 @@ 'use strict'; -jest.mock('opn'); +jest.mock('open'); const webpack = require('webpack'); -const opn = require('opn'); +const open = require('open'); const Server = require('../../lib/Server'); const config = require('../fixtures/simple-config/webpack.config'); -opn.mockImplementation(() => { +open.mockImplementation(() => { return { catch: jest.fn(), }; @@ -21,8 +21,8 @@ describe('open option', () => { }); compiler.hooks.done.tap('webpack-dev-server', () => { - expect(opn.mock.calls[0]).toEqual(['http://localhost:8080/', {}]); - expect(opn.mock.invocationCallOrder[0]).toEqual(1); + expect(open.mock.calls[0]).toEqual(['http://localhost:8080/', {}]); + expect(open.mock.invocationCallOrder[0]).toEqual(1); server.close(done); }); diff --git a/test/server/utils/runOpen.test.js b/test/server/utils/runOpen.test.js index 51fce41300..18da417801 100644 --- a/test/server/utils/runOpen.test.js +++ b/test/server/utils/runOpen.test.js @@ -1,23 +1,23 @@ 'use strict'; -const opn = require('opn'); +const open = require('open'); const runOpen = require('../../../lib/utils/runOpen'); -jest.mock('opn'); +jest.mock('open'); describe('runOpen util', () => { afterEach(() => { - opn.mockClear(); + open.mockClear(); }); describe('should open browser', () => { beforeEach(() => { - opn.mockImplementation(() => Promise.resolve()); + open.mockImplementation(() => Promise.resolve()); }); it('on specify URL', () => { return runOpen('https://example.com', {}, console).then(() => { - expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]); + expect(open.mock.calls[0]).toEqual(['https://example.com', {}]); }); }); @@ -27,7 +27,7 @@ describe('runOpen util', () => { { openPage: '/index.html' }, console ).then(() => { - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com/index.html', {}, ]); @@ -40,7 +40,7 @@ describe('runOpen util', () => { { open: 'Google Chrome' }, console ).then(() => { - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com', { app: 'Google Chrome' }, ]); @@ -53,7 +53,7 @@ describe('runOpen util', () => { { open: 'Google Chrome', openPage: '/index.html' }, console ).then(() => { - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com/index.html', { app: 'Google Chrome' }, ]); @@ -65,7 +65,7 @@ describe('runOpen util', () => { const logMock = { warn: jest.fn() }; beforeEach(() => { - opn.mockImplementation(() => Promise.reject()); + open.mockImplementation(() => Promise.reject()); }); afterEach(() => { @@ -77,7 +77,7 @@ describe('runOpen util', () => { expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( `"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"` ); - expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]); + expect(open.mock.calls[0]).toEqual(['https://example.com', {}]); }); }); @@ -90,7 +90,7 @@ describe('runOpen util', () => { expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( `"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"` ); - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com/index.html', {}, ]); @@ -106,7 +106,7 @@ describe('runOpen util', () => { expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( `"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"` ); - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com', { app: 'Google Chrome', @@ -124,7 +124,7 @@ describe('runOpen util', () => { expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( `"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"` ); - expect(opn.mock.calls[0]).toEqual([ + expect(open.mock.calls[0]).toEqual([ 'https://example.com/index.html', { app: 'Google Chrome' }, ]);