diff --git a/package-lock.json b/package-lock.json index 2918f7a..389c97c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,12 +98,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -1123,12 +1123,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -1552,12 +1552,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "globals": { @@ -2351,9 +2351,9 @@ "dev": true }, "@types/node": { - "version": "14.10.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.1.tgz", - "integrity": "sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ==", + "version": "14.11.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.1.tgz", + "integrity": "sha512-oTQgnd0hblfLsJ6BvJzzSL+Inogp3lq9fGgqRkMB/ziKMgEUaFl801OncOzUmalfzt14N0oPHMK47ipl+wbTIw==", "dev": true }, "@types/normalize-package-data": { @@ -2369,9 +2369,9 @@ "dev": true }, "@types/prettier": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.1.0.tgz", - "integrity": "sha512-hiYA88aHiEIgDmeKlsyVsuQdcFn3Z2VuFd/Xm/HCnGnPD8UFU5BM128uzzRVVGEzKDKYUrRsRH9S2o+NUy/3IA==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.1.1.tgz", + "integrity": "sha512-2zs+O+UkDsJ1Vcp667pd3f8xearMdopz/z54i99wtRDI5KLmngk7vlrYZD0ZjKHaROR03EznlBbVY9PfAEyJIQ==", "dev": true }, "@types/stack-utils": { @@ -3444,14 +3444,14 @@ } }, "browserslist": { - "version": "4.14.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.2.tgz", - "integrity": "sha512-HI4lPveGKUR0x2StIz+2FXfDk9SfVMrxn6PLh1JeGUwcuoDkdKZebWiyLRJ68iIPDpMI4JLVDf7S7XzslgWOhw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.3.tgz", + "integrity": "sha512-GcZPC5+YqyPO4SFnz48/B0YaCwS47Q9iPChRGi6t7HhflKBcINzFrJvRfC+jp30sRMKxF+d4EHGs27Z0XP1NaQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001125", - "electron-to-chromium": "^1.3.564", - "escalade": "^3.0.2", + "caniuse-lite": "^1.0.30001131", + "electron-to-chromium": "^1.3.570", + "escalade": "^3.1.0", "node-releases": "^1.1.61" } }, @@ -3558,9 +3558,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001129", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001129.tgz", - "integrity": "sha512-9945fTVKS810DZITpsAbuhQG7Lam0tEfVbZlsBaCFZaszepbryrArS05PWmJSBQ6mta+v9iz0pUIAbW1eBILIg==", + "version": "1.0.30001132", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001132.tgz", + "integrity": "sha512-zk5FXbnsmHa0Ktc/NOZJRr+ilXva+2KFJuRiQfnjkxJfV/7DYP5C27lSQF++/veCUzVWE5xecZnSBJjf6fSwJA==", "dev": true }, "capture-exit": { @@ -5240,9 +5240,9 @@ } }, "electron-to-chromium": { - "version": "1.3.567", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.567.tgz", - "integrity": "sha512-1aKkw0Hha1Bw9JA5K5PT5eFXC/TXbkJvUfNSNEciPUMgSIsRJZM1hF2GUEAGZpAbgvd8En21EA+Lv820KOhvqA==", + "version": "1.3.570", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.570.tgz", + "integrity": "sha512-Y6OCoVQgFQBP5py6A/06+yWxUZHDlNr/gNDGatjH8AZqXl8X0tE4LfjLJsXGz/JmWJz8a6K7bR1k+QzZ+k//fg==", "dev": true }, "elliptic": { @@ -5377,9 +5377,9 @@ } }, "escalade": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.0.2.tgz", - "integrity": "sha512-gPYAU37hYCUhW5euPeR+Y74F7BL+IBsV93j5cvGriSaD1aG6MGsqsV1yamRdrWrb2j3aiZvb0X+UBOWpx3JWtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.0.tgz", + "integrity": "sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig==", "dev": true }, "escape-string-regexp": { @@ -5540,12 +5540,12 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "glob-parent": { @@ -7712,12 +7712,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -9411,9 +9411,9 @@ "dev": true }, "lint-staged": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.3.0.tgz", - "integrity": "sha512-an3VgjHqmJk0TORB/sdQl0CTkRg4E5ybYCXTTCSJ5h9jFwZbcgKIx5oVma5e7wp/uKt17s1QYFmYqT9MGVosGw==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.4.0.tgz", + "integrity": "sha512-uaiX4U5yERUSiIEQc329vhCTDDwUcSvKdRLsNomkYLRzijk3v8V9GWm2Nz0RMVB87VcuzLvtgy6OsjoH++QHIg==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -9495,12 +9495,12 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "execa": { @@ -11494,9 +11494,9 @@ "dev": true }, "regexpu-core": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.0.tgz", - "integrity": "sha512-TQ4KXRnIn6tz6tjnrXEkD/sshygKH/j5KzK86X8MkeHyZ8qst/LZ89j3X4/8HEIfHANTFIP/AbXakeRhWIl5YQ==", + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.1.tgz", + "integrity": "sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ==", "dev": true, "requires": { "regenerate": "^1.4.0", @@ -12161,9 +12161,9 @@ } }, "spdx-license-ids": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", - "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz", + "integrity": "sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw==", "dev": true }, "split": { @@ -13538,9 +13538,9 @@ "dev": true }, "webpack": { - "version": "4.44.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.44.1.tgz", - "integrity": "sha512-4UOGAohv/VGUNQJstzEywwNxqX417FnjZgZJpJQegddzPmTvph37eBIRbRTfdySXzVtJXLJfbMN3mMYhM6GdmQ==", + "version": "4.44.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.44.2.tgz", + "integrity": "sha512-6KJVGlCxYdISyurpQ0IPTklv+DULv05rs2hseIXer6D7KrUicRDLFb4IUM1S6LUAKypPM/nSiVSuv8jHu1m3/Q==", "dev": true, "requires": { "@webassemblyjs/ast": "1.9.0", diff --git a/package.json b/package.json index a319078..5312a64 100644 --- a/package.json +++ b/package.json @@ -66,12 +66,12 @@ "file-loader": "^6.1.0", "husky": "^4.3.0", "jest": "^26.4.2", - "lint-staged": "^10.3.0", + "lint-staged": "^10.4.0", "memfs": "^3.2.0", "npm-run-all": "^4.1.5", "prettier": "^2.1.2", "standard-version": "^9.0.0", - "webpack": "^4.44.1" + "webpack": "^4.44.2" }, "keywords": [ "webpack" diff --git a/src/index.js b/src/index.js index 9b7d880..bd8690f 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,7 @@ import webpack, { version as webpackVersion, } from 'webpack'; import validateOptions from 'schema-utils'; +import serialize from 'serialize-javascript'; import schema from './options.json'; @@ -52,7 +53,6 @@ class CompressionPlugin { }; this.algorithm = this.options.algorithm; - this.compressionOptions = this.options.compressionOptions; if (typeof this.algorithm === 'string') { // eslint-disable-next-line global-require @@ -66,9 +66,9 @@ class CompressionPlugin { ); } - this.compressionOptions = { + this.options.compressionOptions = { ...{ level: 9 }, - ...this.compressionOptions, + ...this.options.compressionOptions, }; } } @@ -117,20 +117,22 @@ class CompressionPlugin { runCompressionAlgorithm(input) { return new Promise((resolve, reject) => { - const { algorithm, compressionOptions } = this; + this.algorithm( + input, + this.options.compressionOptions, + (error, result) => { + if (error) { + return reject(error); + } - algorithm(input, compressionOptions, (error, result) => { - if (error) { - return reject(error); - } + if (!Buffer.isBuffer(result)) { + // eslint-disable-next-line no-param-reassign + result = Buffer.from(result); + } - if (!Buffer.isBuffer(result)) { - // eslint-disable-next-line no-param-reassign - result = Buffer.from(result); + return resolve(result); } - - return resolve(result); - }); + ); }); } @@ -204,12 +206,16 @@ class CompressionPlugin { 'compression-webpack-plugin': require('../package.json').version, algorithm: this.algorithm, originalAlgorithm: this.options.algorithm, - compressionOptions: this.compressionOptions, + compressionOptions: this.options.compressionOptions, name, contentHash: crypto.createHash('md4').update(input).digest('hex'), }; } else { - cacheData.name = name; + cacheData.name = serialize({ + name, + algorithm: this.options.algorithm, + compressionOptions: this.options.compressionOptions, + }); } let output = await cache.get(cacheData, { RawSource }); @@ -282,7 +288,7 @@ class CompressionPlugin { // TODO `...` required only for webpack@4 const newOriginalInfo = { ...info, - related: { [relatedName]: newName }, + related: { [relatedName]: newName, ...info.related }, }; CompressionPlugin.updateAsset( diff --git a/test/CompressionPlugin.test.js b/test/CompressionPlugin.test.js index dd909fa..873a945 100644 --- a/test/CompressionPlugin.test.js +++ b/test/CompressionPlugin.test.js @@ -23,6 +23,7 @@ import { const cacheDir1 = findCacheDir({ name: 'compression-webpack-plugin-cache-1' }); const cacheDir2 = findCacheDir({ name: 'compression-webpack-plugin-cache-2' }); const cacheDir3 = findCacheDir({ name: 'compression-webpack-plugin-cache-3' }); +const cacheDir4 = findCacheDir({ name: 'compression-webpack-plugin-cache-4' }); describe('CompressionPlugin', () => { beforeAll(() => { @@ -31,6 +32,7 @@ describe('CompressionPlugin', () => { cacache.rm.all(cacheDir1), cacache.rm.all(cacheDir2), cacache.rm.all(cacheDir3), + cacache.rm.all(cacheDir4), ]); }); @@ -69,8 +71,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work with assets info', async () => { @@ -93,8 +95,8 @@ describe('CompressionPlugin', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats, true)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work child compilations', async () => { @@ -139,8 +141,8 @@ describe('CompressionPlugin', () => { expect(gzipSpy).toHaveBeenCalledTimes(5); expect(getAssetsNameAndSize(stats, true)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); gzipSpy.mockRestore(); }); @@ -167,14 +169,16 @@ describe('CompressionPlugin', () => { filename: '[path][base].br', }).apply(compiler); new CompressionPlugin({ + minRatio: Infinity, algorithm: (input, options, callback) => { - return callback(input); + return callback(null, input); }, filename: '[path][base].compress', }).apply(compiler); new CompressionPlugin({ + minRatio: Infinity, algorithm: (input, options, callback) => { - return callback(input); + return callback(null, input); }, filename: '[path][base].custom?foo=bar#hash', }).apply(compiler); @@ -182,8 +186,8 @@ describe('CompressionPlugin', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats, true)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work and show compress assets in stats', async () => { @@ -210,8 +214,8 @@ describe('CompressionPlugin', () => { getCompiler.isWebpack4() ? 0 : 3 ); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work and keep assets info', async () => { @@ -237,8 +241,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work and use memory cache without options in the "development" mode', async () => { @@ -265,8 +269,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -326,8 +330,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -387,8 +391,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); new ModifyExistingAsset({ name: 'main.js' }).apply(compiler); @@ -415,6 +419,81 @@ describe('CompressionPlugin', () => { }); }); + it('should work and use memory cache when the "cache" option is "true" with multiple plugins', async () => { + const getCacheDirectorySpy = jest + .spyOn(Webpack4Cache, 'getCacheDirectory') + .mockImplementation(() => { + return cacheDir4; + }); + + const compiler = getCompiler( + './entry.js', + {}, + { + cache: true, + output: { + path: path.resolve(__dirname, './outputs'), + filename: '[name].js', + chunkFilename: '[id].js', + }, + } + ); + + new CompressionPlugin({ + filename: '[path][base].gz', + algorithm: 'gzip', + }).apply(compiler); + new CompressionPlugin({ + filename: '[path][base].br', + algorithm: 'brotliCompress', + }).apply(compiler); + new CompressionPlugin({ + minRatio: Infinity, + algorithm: (input, options, callback) => { + return callback(null, input); + }, + filename: '[path][base].custom', + }).apply(compiler); + + const stats = await compile(compiler); + + if (webpack.version[0] === '4') { + expect( + Object.keys(stats.compilation.assets).filter( + (assetName) => stats.compilation.assets[assetName].emitted + ).length + ).toBe(14); + } else { + expect(stats.compilation.emittedAssets.size).toBe(14); + } + + expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + + await new Promise(async (resolve) => { + const newStats = await compile(compiler); + + if (webpack.version[0] === '4') { + expect( + Object.keys(newStats.compilation.assets).filter( + (assetName) => newStats.compilation.assets[assetName].emitted + ).length + ).toBe(0); + } else { + expect(newStats.compilation.emittedAssets.size).toBe(0); + } + + expect(getAssetsNameAndSize(newStats)).toMatchSnapshot('assets'); + expect(getWarnings(newStats)).toMatchSnapshot('errors'); + expect(getErrors(newStats)).toMatchSnapshot('warnings'); + + getCacheDirectorySpy.mockRestore(); + + resolve(); + }); + }); + it('should work and do not use memory cache when the "cache" option is "false"', async () => { const compiler = getCompiler( './entry.js', @@ -448,8 +527,8 @@ describe('CompressionPlugin', () => { } expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); diff --git a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4 b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4 index 05aeffb..6c064a8 100644 --- a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4 +++ b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4 @@ -222,6 +222,136 @@ exports[`CompressionPlugin should work and use memory cache when the "cache" opt exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" and the asset has been changed: warnings 2`] = `Array []`; +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: assets 1`] = ` +Array [ + Array [ + "09a1a1112c577c2794359715edfcb5ac.png", + 78117, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom", + 78117, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.br", + 363, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.custom", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.gz", + 393, + ], + Array [ + "async.js", + 249, + ], + Array [ + "async.js.br", + 141, + ], + Array [ + "async.js.custom", + 249, + ], + Array [ + "async.js.gz", + 171, + ], + Array [ + "main.js", + 11549, + ], + Array [ + "main.js.br", + 2546, + ], + Array [ + "main.js.custom", + 11549, + ], + Array [ + "main.js.gz", + 2953, + ], +] +`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: assets 2`] = ` +Array [ + Array [ + "09a1a1112c577c2794359715edfcb5ac.png", + 78117, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom", + 78117, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.br", + 363, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.custom", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.gz", + 393, + ], + Array [ + "async.js", + 249, + ], + Array [ + "async.js.br", + 141, + ], + Array [ + "async.js.custom", + 249, + ], + Array [ + "async.js.gz", + 171, + ], + Array [ + "main.js", + 11549, + ], + Array [ + "main.js.br", + 2546, + ], + Array [ + "main.js.custom", + 11549, + ], + Array [ + "main.js.gz", + 2953, + ], +] +`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: errors 1`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: errors 2`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: warnings 1`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: warnings 2`] = `Array []`; + exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true": assets 1`] = ` Array [ Array [ @@ -575,6 +705,26 @@ Array [ 78117, Object { "immutable": true, + "related": Object { + "compressed": "09a1a1112c577c2794359715edfcb5ac.png.compress", + "customed": "09a1a1112c577c2794359715edfcb5ac.png.custom?foo=bar#hash", + }, + }, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.compress", + 78117, + Object { + "compressed": true, + "immutable": true, + }, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom?foo=bar#hash", + 78117, + Object { + "compressed": true, + "immutable": true, }, ], Array [ @@ -584,6 +734,9 @@ Array [ "immutable": true, "related": Object { "brotliCompressed": "23fc1d3ac606d117e05a140e0de79806.svg.br", + "compressed": "23fc1d3ac606d117e05a140e0de79806.svg.compress", + "customed": "23fc1d3ac606d117e05a140e0de79806.svg.custom?foo=bar#hash", + "gziped": "23fc1d3ac606d117e05a140e0de79806.svg.gz", }, }, ], @@ -595,6 +748,22 @@ Array [ "immutable": true, }, ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.compress", + 672, + Object { + "compressed": true, + "immutable": true, + }, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.custom?foo=bar#hash", + 672, + Object { + "compressed": true, + "immutable": true, + }, + ], Array [ "23fc1d3ac606d117e05a140e0de79806.svg.gz", 393, @@ -611,6 +780,22 @@ Array [ "immutable": true, }, ], + Array [ + "async.async.js.compress", + 249, + Object { + "compressed": true, + "immutable": true, + }, + ], + Array [ + "async.async.js.custom?foo=bar#hash", + 249, + Object { + "compressed": true, + "immutable": true, + }, + ], Array [ "async.async.js.gz", 171, @@ -626,6 +811,9 @@ Array [ "immutable": true, "related": Object { "brotliCompressed": "async.async.js.br", + "compressed": "async.async.js.compress", + "customed": "async.async.js.custom?foo=bar#hash", + "gziped": "async.async.js.gz", }, }, ], @@ -637,6 +825,22 @@ Array [ "immutable": true, }, ], + Array [ + "main.js.compress", + 11630, + Object { + "compressed": true, + "immutable": true, + }, + ], + Array [ + "main.js.custom?foo=bar#hash", + 11630, + Object { + "compressed": true, + "immutable": true, + }, + ], Array [ "main.js.gz", 3002, @@ -652,6 +856,9 @@ Array [ "immutable": true, "related": Object { "brotliCompressed": "main.js.br", + "compressed": "main.js.compress", + "customed": "main.js.custom?foo=bar#hash", + "gziped": "main.js.gz", }, }, ], @@ -660,24 +867,7 @@ Array [ exports[`CompressionPlugin should work with multiple plugins: errors 1`] = `Array []`; -exports[`CompressionPlugin should work with multiple plugins: warnings 1`] = ` -Array [ - "�PNG -", - "icon", - "(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"async\\"],{ -", - "/******/ (function(modules) { // webpackBootstrap -/******/ // install a JSONP callback for chunk loading", - "�PNG -", - "icon", - "(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"async\\"],{ -", - "/******/ (function(modules) { // webpackBootstrap -/******/ // install a JSONP callback for chunk loading", -] -`; +exports[`CompressionPlugin should work with multiple plugins: warnings 1`] = `Array []`; exports[`CompressionPlugin should work: assets 1`] = ` Array [ diff --git a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5 b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5 index f4b31c9..31b19cd 100644 --- a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5 +++ b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5 @@ -24,11 +24,11 @@ Array [ ], Array [ "main.js", - 14990, + 16390, ], Array [ "main.js.gz", - 3451, + 3839, ], ] `; @@ -57,11 +57,11 @@ Array [ ], Array [ "main.js", - 14990, + 16390, ], Array [ "main.js.gz", - 3451, + 3839, ], ] `; @@ -97,12 +97,12 @@ Array [ 179, ], Array [ - "main.c7afb01b272238013361.js", - 15077, + "main.1dbd2c97402fe5e0aff0.js", + 16477, ], Array [ - "main.c7afb01b272238013361.js.gz", - 3538, + "main.1dbd2c97402fe5e0aff0.js.gz", + 3926, ], ] `; @@ -135,11 +135,11 @@ Array [ ], Array [ "main.js", - 15046, + 16446, ], Array [ "main.js.gz", - 3519, + 3903, ], ] `; @@ -172,11 +172,11 @@ Array [ ], Array [ "main.js", - 15030, + 16430, ], Array [ "main.js.gz", - 3512, + 3900, ], ] `; @@ -205,11 +205,11 @@ Array [ ], Array [ "main.js", - 15052, + 16452, ], Array [ "main.js.gz", - 3523, + 3911, ], ] `; @@ -222,6 +222,136 @@ exports[`CompressionPlugin should work and use memory cache when the "cache" opt exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" and the asset has been changed: warnings 2`] = `Array []`; +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: assets 1`] = ` +Array [ + Array [ + "09a1a1112c577c2794359715edfcb5ac.png", + 78117, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom", + 78117, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.br", + 363, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.custom", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.gz", + 393, + ], + Array [ + "async.js", + 265, + ], + Array [ + "async.js.br", + 146, + ], + Array [ + "async.js.custom", + 265, + ], + Array [ + "async.js.gz", + 179, + ], + Array [ + "main.js", + 16430, + ], + Array [ + "main.js.br", + 3391, + ], + Array [ + "main.js.custom", + 16430, + ], + Array [ + "main.js.gz", + 3900, + ], +] +`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: assets 2`] = ` +Array [ + Array [ + "09a1a1112c577c2794359715edfcb5ac.png", + 78117, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom", + 78117, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.br", + 363, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.custom", + 672, + ], + Array [ + "23fc1d3ac606d117e05a140e0de79806.svg.gz", + 393, + ], + Array [ + "async.js", + 265, + ], + Array [ + "async.js.br", + 146, + ], + Array [ + "async.js.custom", + 265, + ], + Array [ + "async.js.gz", + 179, + ], + Array [ + "main.js", + 16430, + ], + Array [ + "main.js.br", + 3391, + ], + Array [ + "main.js.custom", + 16430, + ], + Array [ + "main.js.gz", + 3900, + ], +] +`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: errors 1`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: errors 2`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: warnings 1`] = `Array []`; + +exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true" with multiple plugins: warnings 2`] = `Array []`; + exports[`CompressionPlugin should work and use memory cache when the "cache" option is "true": assets 1`] = ` Array [ Array [ @@ -246,11 +376,11 @@ Array [ ], Array [ "main.js", - 15030, + 16430, ], Array [ "main.js.gz", - 3512, + 3900, ], ] `; @@ -279,11 +409,11 @@ Array [ ], Array [ "main.js", - 15030, + 16430, ], Array [ "main.js.gz", - 3512, + 3900, ], ] `; @@ -319,12 +449,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -352,12 +482,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -410,10 +540,10 @@ Array [ }, ], Array [ - "async.async.js?ver=14fadf4633f3cc38b89b", + "async.async.js?ver=931a10b06a9f000536b2", 265, Object { - "fullhash": "14fadf4633f3cc38b89b", + "fullhash": "931a10b06a9f000536b2", "immutable": true, "related": Object { "gziped": "async.async.js.gz", @@ -442,23 +572,23 @@ Array [ ], Array [ "main.js.gz", - 3563, + 3947, Object { "compressed": true, "immutable": true, - "size": 3563, + "size": 3947, }, ], Array [ - "main.js?var=14fadf4633f3cc38b89b", - 15233, + "main.js?var=931a10b06a9f000536b2", + 16633, Object { - "fullhash": "14fadf4633f3cc38b89b", + "fullhash": "931a10b06a9f000536b2", "immutable": true, "related": Object { "gziped": "main.js.gz", }, - "size": 15233, + "size": 16633, }, ], ] @@ -500,15 +630,15 @@ Array [ ], Array [ "async.async.js.gz", - 235, + 233, Object { "compressed": true, "immutable": true, - "size": 235, + "size": 233, }, ], Array [ - "async.async.js.map?ver=bbf6508f271a84a2c39d", + "async.async.js.map?ver=2b96998c4528126e8d99", 116, Object { "development": true, @@ -516,14 +646,14 @@ Array [ }, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 330, Object { - "fullhash": "bbf6508f271a84a2c39d", + "fullhash": "2b96998c4528126e8d99", "immutable": true, "related": Object { "gziped": "async.async.js.gz", - "sourceMap": "async.async.js.map?ver=bbf6508f271a84a2c39d", + "sourceMap": "async.async.js.map?ver=2b96998c4528126e8d99", }, "size": 330, }, @@ -549,43 +679,43 @@ Array [ ], Array [ "main.js.gz", - 3598, + 3983, Object { "compressed": true, "immutable": true, - "size": 3598, + "size": 3983, }, ], Array [ "main.js.map.gz", - 3570, + 3956, Object { "compressed": true, - "size": 3570, + "size": 3956, }, ], Array [ - "main.js.map?var=bbf6508f271a84a2c39d", - 11145, + "main.js.map?var=2b96998c4528126e8d99", + 12430, Object { "development": true, "related": Object { "gziped": "main.js.map.gz", }, - "size": 11145, + "size": 12430, }, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15294, + "main.js?var=2b96998c4528126e8d99", + 16694, Object { - "fullhash": "bbf6508f271a84a2c39d", + "fullhash": "2b96998c4528126e8d99", "immutable": true, "related": Object { "gziped": "main.js.gz", - "sourceMap": "main.js.map?var=bbf6508f271a84a2c39d", + "sourceMap": "main.js.map?var=2b96998c4528126e8d99", }, - "size": 15294, + "size": 16694, }, ], ] @@ -601,6 +731,28 @@ Array [ "09a1a1112c577c2794359715edfcb5ac.png", 78117, Object { + "immutable": true, + "related": Object { + "compressed": "09a1a1112c577c2794359715edfcb5ac.png.compress", + "customed": "09a1a1112c577c2794359715edfcb5ac.png.custom?foo=bar#hash", + }, + "size": 78117, + }, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.compress", + 78117, + Object { + "compressed": true, + "immutable": true, + "size": 78117, + }, + ], + Array [ + "09a1a1112c577c2794359715edfcb5ac.png.custom?foo=bar#hash", + 78117, + Object { + "compressed": true, "immutable": true, "size": 78117, }, @@ -621,29 +773,29 @@ Array [ ], Array [ "23fc1d3ac606d117e05a140e0de79806.svg.br", - 393, + 363, Object { "compressed": true, "immutable": true, - "size": 393, + "size": 363, }, ], Array [ "23fc1d3ac606d117e05a140e0de79806.svg.compress", - 393, + 672, Object { "compressed": true, "immutable": true, - "size": 393, + "size": 672, }, ], Array [ "23fc1d3ac606d117e05a140e0de79806.svg.custom?foo=bar#hash", - 393, + 672, Object { "compressed": true, "immutable": true, - "size": 393, + "size": 672, }, ], Array [ @@ -657,29 +809,29 @@ Array [ ], Array [ "async.async.js.br", - 179, + 146, Object { "compressed": true, "immutable": true, - "size": 179, + "size": 146, }, ], Array [ "async.async.js.compress", - 179, + 265, Object { "compressed": true, "immutable": true, - "size": 179, + "size": 265, }, ], Array [ "async.async.js.custom?foo=bar#hash", - 179, + 265, Object { "compressed": true, "immutable": true, - "size": 179, + "size": 265, }, ], Array [ @@ -692,10 +844,10 @@ Array [ }, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, Object { - "fullhash": "bbf6508f271a84a2c39d", + "fullhash": "2b96998c4528126e8d99", "immutable": true, "related": Object { "brotliCompressed": "async.async.js.br", @@ -708,45 +860,45 @@ Array [ ], Array [ "main.js.br", - 3567, + 3436, Object { "compressed": true, "immutable": true, - "size": 3567, + "size": 3436, }, ], Array [ "main.js.compress", - 3567, + 16636, Object { "compressed": true, "immutable": true, - "size": 3567, + "size": 16636, }, ], Array [ "main.js.custom?foo=bar#hash", - 3567, + 16636, Object { "compressed": true, "immutable": true, - "size": 3567, + "size": 16636, }, ], Array [ "main.js.gz", - 3567, + 3953, Object { "compressed": true, "immutable": true, - "size": 3567, + "size": 3953, }, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, Object { - "fullhash": "bbf6508f271a84a2c39d", + "fullhash": "2b96998c4528126e8d99", "immutable": true, "related": Object { "brotliCompressed": "main.js.br", @@ -754,7 +906,7 @@ Array [ "customed": "main.js.custom?foo=bar#hash", "gziped": "main.js.gz", }, - "size": 15236, + "size": 16636, }, ], ] @@ -783,16 +935,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; diff --git a/test/__snapshots__/algorithm.test.js.snap.webpack4 b/test/__snapshots__/algorithm.test.js.snap.webpack4 index 9fb1560..5808f05 100644 --- a/test/__snapshots__/algorithm.test.js.snap.webpack4 +++ b/test/__snapshots__/algorithm.test.js.snap.webpack4 @@ -121,9 +121,7 @@ exports[`"algorithm" option matches snapshot for custom function with error ({Fu exports[`"algorithm" option matches snapshot for custom function with error ({Function}): compressionOptions 4`] = `Object {}`; -exports[`"algorithm" option matches snapshot for custom function with error ({Function}): errors 1`] = `Array []`; - -exports[`"algorithm" option matches snapshot for custom function with error ({Function}): warnings 1`] = ` +exports[`"algorithm" option matches snapshot for custom function with error ({Function}): errors 1`] = ` Array [ "Error", "Error", @@ -131,3 +129,5 @@ Array [ "Error", ] `; + +exports[`"algorithm" option matches snapshot for custom function with error ({Function}): warnings 1`] = `Array []`; diff --git a/test/__snapshots__/algorithm.test.js.snap.webpack5 b/test/__snapshots__/algorithm.test.js.snap.webpack5 index 7b0d430..4e55bf2 100644 --- a/test/__snapshots__/algorithm.test.js.snap.webpack5 +++ b/test/__snapshots__/algorithm.test.js.snap.webpack5 @@ -27,12 +27,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -70,12 +70,12 @@ Array [ 265, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 15077, + "main.549e08e1b71de97c7e36.js.gz", + 16477, ], ] `; @@ -107,8 +107,8 @@ Array [ 265, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], ] `; @@ -121,9 +121,7 @@ exports[`"algorithm" option matches snapshot for custom function with error ({Fu exports[`"algorithm" option matches snapshot for custom function with error ({Function}): compressionOptions 4`] = `Object {}`; -exports[`"algorithm" option matches snapshot for custom function with error ({Function}): errors 1`] = `Array []`; - -exports[`"algorithm" option matches snapshot for custom function with error ({Function}): warnings 1`] = ` +exports[`"algorithm" option matches snapshot for custom function with error ({Function}): errors 1`] = ` Array [ "Error", "Error", @@ -131,3 +129,5 @@ Array [ "Error", ] `; + +exports[`"algorithm" option matches snapshot for custom function with error ({Function}): warnings 1`] = `Array []`; diff --git a/test/__snapshots__/cache-option.test.js.snap.webpack5 b/test/__snapshots__/cache-option.test.js.snap.webpack5 index 7a3c231..204a326 100644 --- a/test/__snapshots__/cache-option.test.js.snap.webpack5 +++ b/test/__snapshots__/cache-option.test.js.snap.webpack5 @@ -23,12 +23,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -56,12 +56,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -97,12 +97,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -130,12 +130,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -171,12 +171,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -204,12 +204,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -245,12 +245,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -278,12 +278,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; diff --git a/test/__snapshots__/compressionOptions-option.test.js.snap.webpack5 b/test/__snapshots__/compressionOptions-option.test.js.snap.webpack5 index f32dc62..589e678 100644 --- a/test/__snapshots__/compressionOptions-option.test.js.snap.webpack5 +++ b/test/__snapshots__/compressionOptions-option.test.js.snap.webpack5 @@ -27,12 +27,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -68,12 +68,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; diff --git a/test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack5 b/test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack5 index 1aceb77..1609147 100644 --- a/test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack5 +++ b/test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack5 @@ -27,12 +27,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -56,8 +56,8 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; diff --git a/test/__snapshots__/exclude-option.test.js.snap.webpack5 b/test/__snapshots__/exclude-option.test.js.snap.webpack5 index 2ec61d5..25f57b4 100644 --- a/test/__snapshots__/exclude-option.test.js.snap.webpack5 +++ b/test/__snapshots__/exclude-option.test.js.snap.webpack5 @@ -19,16 +19,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; @@ -52,16 +52,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; diff --git a/test/__snapshots__/filename-option.test.js.snap.webpack5 b/test/__snapshots__/filename-option.test.js.snap.webpack5 index 8b02240..605b8c0 100644 --- a/test/__snapshots__/filename-option.test.js.snap.webpack5 +++ b/test/__snapshots__/filename-option.test.js.snap.webpack5 @@ -19,20 +19,20 @@ Array [ 672, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ - "async.async.super-compressed.js.gz?ver=bbf6508f271a84a2c39d", + "async.async.super-compressed.js.gz?ver=2b96998c4528126e8d99", 179, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], Array [ - "main.super-compressed.js.gz?var=bbf6508f271a84a2c39d", - 3567, + "main.super-compressed.js.gz?var=2b96998c4528126e8d99", + 3953, ], ] `; @@ -60,20 +60,20 @@ Array [ 393, ], Array [ - "assets/js/async.async.js.super-compressed.gz?ver=d31d295ee8d5ebdf41b4#hash", + "assets/js/async.async.js.super-compressed.gz?ver=71922e2bd2fa2c7cd08b#hash", 179, ], Array [ - "assets/js/async.async.js?ver=d31d295ee8d5ebdf41b4#hash", + "assets/js/async.async.js?ver=71922e2bd2fa2c7cd08b#hash", 265, ], Array [ - "assets/js/main.js.super-compressed.gz?var=d31d295ee8d5ebdf41b4#hash", - 3578, + "assets/js/main.js.super-compressed.gz?var=71922e2bd2fa2c7cd08b#hash", + 3970, ], Array [ - "assets/js/main.js?var=d31d295ee8d5ebdf41b4#hash", - 15251, + "assets/js/main.js?var=71922e2bd2fa2c7cd08b#hash", + 16662, ], ] `; @@ -101,20 +101,20 @@ Array [ 393, ], Array [ - "async.async.js.gz?ver=e0cd056ace173b6df0d1", + "async.async.js.gz?ver=2b50bacb8fd8b55de9f3", 179, ], Array [ - "async.async.js?ver=e0cd056ace173b6df0d1#hash", + "async.async.js?ver=2b50bacb8fd8b55de9f3#hash", 265, ], Array [ - "main.js.gz?var=e0cd056ace173b6df0d1", - 3568, + "main.js.gz?var=2b50bacb8fd8b55de9f3", + 3957, ], Array [ - "main.js?var=e0cd056ace173b6df0d1#hash", - 15241, + "main.js?var=2b50bacb8fd8b55de9f3#hash", + 16641, ], ] `; @@ -146,16 +146,16 @@ Array [ 179, ], Array [ - "assets/scripts/async.async.js?ver=50393f48e1956509615a#hash", + "assets/scripts/async.async.js?ver=8f8db7cc1a5687aada31#hash", 265, ], Array [ "assets/scripts/main.js.gz", - 3581, + 3971, ], Array [ - "assets/scripts/main.js?var=50393f48e1956509615a#hash", - 15256, + "assets/scripts/main.js?var=8f8db7cc1a5687aada31#hash", + 16667, ], ] `; diff --git a/test/__snapshots__/include-option.test.js.snap.webpack5 b/test/__snapshots__/include-option.test.js.snap.webpack5 index 76ed6ec..1418196 100644 --- a/test/__snapshots__/include-option.test.js.snap.webpack5 +++ b/test/__snapshots__/include-option.test.js.snap.webpack5 @@ -15,16 +15,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; @@ -52,16 +52,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; diff --git a/test/__snapshots__/minRatio-option.test.js.snap.webpack5 b/test/__snapshots__/minRatio-option.test.js.snap.webpack5 index 5e3368f..5ef8c95 100644 --- a/test/__snapshots__/minRatio-option.test.js.snap.webpack5 +++ b/test/__snapshots__/minRatio-option.test.js.snap.webpack5 @@ -15,8 +15,8 @@ Array [ 265, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], ] `; @@ -52,12 +52,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; diff --git a/test/__snapshots__/test-option.test.js.snap.webpack5 b/test/__snapshots__/test-option.test.js.snap.webpack5 index d3408d2..719da82 100644 --- a/test/__snapshots__/test-option.test.js.snap.webpack5 +++ b/test/__snapshots__/test-option.test.js.snap.webpack5 @@ -15,12 +15,12 @@ Array [ 672, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; @@ -48,12 +48,12 @@ Array [ 393, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; @@ -85,16 +85,16 @@ Array [ 179, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ "main.js.gz", - 3567, + 3953, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; @@ -114,12 +114,12 @@ Array [ 672, ], Array [ - "async.async.js?ver=bbf6508f271a84a2c39d", + "async.async.js?ver=2b96998c4528126e8d99", 265, ], Array [ - "main.js?var=bbf6508f271a84a2c39d", - 15236, + "main.js?var=2b96998c4528126e8d99", + 16636, ], ] `; diff --git a/test/__snapshots__/threshold-option.test.js.snap.webpack5 b/test/__snapshots__/threshold-option.test.js.snap.webpack5 index c89ef90..a3a3ca9 100644 --- a/test/__snapshots__/threshold-option.test.js.snap.webpack5 +++ b/test/__snapshots__/threshold-option.test.js.snap.webpack5 @@ -27,12 +27,12 @@ Array [ 179, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -60,12 +60,12 @@ Array [ 265, ], Array [ - "main.33caac5e08ae5fb270ef.js", - 15077, + "main.549e08e1b71de97c7e36.js", + 16477, ], Array [ - "main.33caac5e08ae5fb270ef.js.gz", - 3538, + "main.549e08e1b71de97c7e36.js.gz", + 3926, ], ] `; @@ -81,12 +81,12 @@ Array [ 0, ], Array [ - "main.d6c14561219fdba42701.js", - 4496, + "main.dddc034f0f06505ce1db.js", + 5896, ], Array [ - "main.d6c14561219fdba42701.js.gz", - 1163, + "main.dddc034f0f06505ce1db.js.gz", + 1608, ], ] `; @@ -106,12 +106,12 @@ Array [ 20, ], Array [ - "main.d6c14561219fdba42701.js", - 4496, + "main.dddc034f0f06505ce1db.js", + 5896, ], Array [ - "main.d6c14561219fdba42701.js.gz", - 1163, + "main.dddc034f0f06505ce1db.js.gz", + 1608, ], ] `; diff --git a/test/algorithm.test.js b/test/algorithm.test.js index 9ae8d6e..4a5d5b0 100644 --- a/test/algorithm.test.js +++ b/test/algorithm.test.js @@ -36,8 +36,8 @@ describe('"algorithm" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for custom function ({Function})', async () => { @@ -53,8 +53,8 @@ describe('"algorithm" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for custom function with error ({Function})', async () => { @@ -70,7 +70,7 @@ describe('"algorithm" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/cache-option.test.js b/test/cache-option.test.js index c047d27..62e0a97 100644 --- a/test/cache-option.test.js +++ b/test/cache-option.test.js @@ -53,8 +53,8 @@ if (getCompiler.isWebpack4()) { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); // Cache disabled so we don't run `get` or `put` expect(cacache.get.mock.calls.length).toBe(0); @@ -87,8 +87,8 @@ if (getCompiler.isWebpack4()) { const stats = await compile(beforeCacheCompiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); const countAssets = Object.keys(stats.compilation.assets).length; @@ -153,8 +153,8 @@ if (getCompiler.isWebpack4()) { const stats = await compile(beforeCacheCompiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); const countAssets = Object.keys(stats.compilation.assets).length; @@ -226,8 +226,8 @@ if (getCompiler.isWebpack4()) { const stats = await compile(beforeCacheCompiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); const countAssets = Object.keys(stats.compilation.assets).length; diff --git a/test/compressionOptions-option.test.js b/test/compressionOptions-option.test.js index f3939c5..b643b33 100644 --- a/test/compressionOptions-option.test.js +++ b/test/compressionOptions-option.test.js @@ -26,8 +26,8 @@ describe('"compressionOptions" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for custom options ({Object})', async () => { @@ -41,7 +41,7 @@ describe('"compressionOptions" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/deleteOriginalAssets.test.js b/test/deleteOriginalAssets.test.js index 77afd73..5da1f5e 100644 --- a/test/deleteOriginalAssets.test.js +++ b/test/deleteOriginalAssets.test.js @@ -27,8 +27,8 @@ describe('"deleteOriginalAssets" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for `false` value ({Boolean})', async () => { @@ -40,7 +40,7 @@ describe('"deleteOriginalAssets" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/exclude-option.test.js b/test/exclude-option.test.js index b4474c0..e49de6d 100644 --- a/test/exclude-option.test.js +++ b/test/exclude-option.test.js @@ -37,8 +37,8 @@ describe('"exclude" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for multiple `exclude` values ({Array})', async () => { @@ -50,7 +50,7 @@ describe('"exclude" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/filename-option.test.js b/test/filename-option.test.js index 82a8415..8c3ca59 100644 --- a/test/filename-option.test.js +++ b/test/filename-option.test.js @@ -38,8 +38,8 @@ describe('"filename" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for `[path][base].super-compressed.gz[query][fragment]` value ({String})', async () => { @@ -63,8 +63,8 @@ describe('"filename" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for `[name][ext].super-compressed.gz[query]` value ({String})', async () => { @@ -88,8 +88,8 @@ describe('"filename" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for custom function ({Function})', async () => { @@ -115,7 +115,7 @@ describe('"filename" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/include-option.test.js b/test/include-option.test.js index 30f21f3..d10a917 100644 --- a/test/include-option.test.js +++ b/test/include-option.test.js @@ -37,8 +37,8 @@ describe('"include" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for multiple `include` values ({Array})', async () => { @@ -50,7 +50,7 @@ describe('"include" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/minRatio-option.test.js b/test/minRatio-option.test.js index bbb6b41..a03a5cc 100644 --- a/test/minRatio-option.test.js +++ b/test/minRatio-option.test.js @@ -26,8 +26,8 @@ describe('"minRatio" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for `1` value ({Number})', async () => { @@ -38,7 +38,7 @@ describe('"minRatio" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/test-option.test.js b/test/test-option.test.js index 980e92d..51a2908 100644 --- a/test/test-option.test.js +++ b/test/test-option.test.js @@ -36,8 +36,8 @@ describe('"test" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for a single `test` value ({RegExp})', async () => { @@ -49,8 +49,8 @@ describe('"test" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for multiple `test` values ({Array})', async () => { @@ -62,8 +62,8 @@ describe('"test" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should work when no asset to compress ', async () => { @@ -75,7 +75,7 @@ describe('"test" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); }); diff --git a/test/threshold-option.test.js b/test/threshold-option.test.js index 5c6e91b..1b96969 100644 --- a/test/threshold-option.test.js +++ b/test/threshold-option.test.js @@ -27,8 +27,8 @@ describe('"threshold" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('matches snapshot for `8192` value ({Number})', async () => { @@ -40,8 +40,8 @@ describe('"threshold" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should compress all assets including assets with "0" bytes original size', async () => { @@ -55,8 +55,8 @@ describe('"threshold" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); it('should compress all assets excluding assets with "0" bytes original size', async () => { @@ -70,7 +70,7 @@ describe('"threshold" option', () => { const stats = await compile(compiler); expect(getAssetsNameAndSize(stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); }); });