Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split tests for webpack 5 #195

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: pr comments
  • Loading branch information
Sergey Melyukov committed Dec 10, 2019
commit 53bceb9b057fe468a97be6fbc8cdc1c55a38a8e6
12 changes: 5 additions & 7 deletions test/TerserPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ describe('TerserPlugin', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
});

if (getCompiler.isWebpack4()) {
it('should regenerate hash', async () => {
it('should regenerate hash', async () => {
if (getCompiler.isWebpack4()) {
const originalMainTemplateUpdateHashForChunk =
smelukov marked this conversation as resolved.
Show resolved Hide resolved
MainTemplate.prototype.updateHashForChunk;
const originalChunkTemplateUpdateHashForChunk =
Expand Down Expand Up @@ -232,9 +232,7 @@ describe('TerserPlugin', () => {

MainTemplate.prototype.updateHashForChunk = originalMainTemplateUpdateHashForChunk;
ChunkTemplate.prototype.updateHashForChunk = originalChunkTemplateUpdateHashForChunk;
});
} else {
it('should regenerate hash', async () => {
} else {
const mockUpdateHashForChunk = jest.fn();
const compiler = getCompiler({
entry: {
Expand Down Expand Up @@ -271,8 +269,8 @@ describe('TerserPlugin', () => {
expect(mockUpdateHashForChunk).toHaveBeenCalledTimes(10);

expect(readsAssets(compiler, stats)).toMatchSnapshot('assets');
});
}
}
});

it('isSourceMap method', () => {
expect(TerserPlugin.isSourceMap(null)).toBe(false);
Expand Down
172 changes: 172 additions & 0 deletions test/__snapshots__/cache-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cache option should match snapshot and invalid cache when entry point was renamed: assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot and invalid cache when entry point was renamed: assets 2`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"onne.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot and invalid cache when entry point was renamed: errors 1`] = `Array []`;

exports[`cache option should match snapshot and invalid cache when entry point was renamed: errors 2`] = `Array []`;

exports[`cache option should match snapshot and invalid cache when entry point was renamed: warnings 1`] = `Array []`;

exports[`cache option should match snapshot and invalid cache when entry point was renamed: warnings 2`] = `Array []`;

exports[`cache option should match snapshot for errors into the "cacheKeys" option: errors 1`] = `
Array [
"Error: one.js from Terser
Error: message",
"Error: two.js from Terser
Error: message",
"Error: three.js from Terser
Error: message",
"Error: four.js from Terser
Error: message",
"Error: five.js from Terser
Error: message",
]
`;

exports[`cache option should match snapshot for errors into the "cacheKeys" option: warnings 1`] = `Array []`;

exports[`cache option should match snapshot for the "false" value: assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot for the "false" value: errors 1`] = `Array []`;

exports[`cache option should match snapshot for the "false" value: warnings 1`] = `Array []`;

exports[`cache option should match snapshot for the "other-cache-directory" value: assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot for the "other-cache-directory" value: assets 2`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot for the "other-cache-directory" value: errors 1`] = `Array []`;

exports[`cache option should match snapshot for the "other-cache-directory" value: errors 2`] = `Array []`;

exports[`cache option should match snapshot for the "other-cache-directory" value: warnings 1`] = `Array []`;

exports[`cache option should match snapshot for the "other-cache-directory" value: warnings 2`] = `Array []`;

exports[`cache option should match snapshot for the "true" value: assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot for the "true" value: assets 2`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot for the "true" value: errors 1`] = `Array []`;

exports[`cache option should match snapshot for the "true" value: errors 2`] = `Array []`;

exports[`cache option should match snapshot for the "true" value: warnings 1`] = `Array []`;

exports[`cache option should match snapshot for the "true" value: warnings 2`] = `Array []`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": assets 2`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": errors 1`] = `Array []`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": errors 2`] = `Array []`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": warnings 1`] = `Array []`;

exports[`cache option should match snapshot when "cacheKey" is custom "function": warnings 2`] = `Array []`;

exports[`cache option should match snapshot when a value is not specify: assets 1`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot when a value is not specify: assets 2`] = `
Object {
"five.js": "(()=>{var r={798:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(798)})();",
"four.js": "(()=>{var r={26:r=>{r.exports=class{}}},t={};!function e(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return r[s](o,o.exports,e),o.exports}(26)})();",
"one.js": "(()=>{var r={73:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(73)})();",
"three.js": "(()=>{var r={800:r=>{r.exports=()=>/test/}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(800)})();",
"two.js": "(()=>{var r={370:r=>{r.exports=\\"string\\"}},t={};!function e(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return r[o](s,s.exports,e),s.exports}(370)})();",
}
`;

exports[`cache option should match snapshot when a value is not specify: errors 1`] = `Array []`;

exports[`cache option should match snapshot when a value is not specify: errors 2`] = `Array []`;

exports[`cache option should match snapshot when a value is not specify: warnings 1`] = `Array []`;

exports[`cache option should match snapshot when a value is not specify: warnings 2`] = `Array []`;
11 changes: 11 additions & 0 deletions test/__snapshots__/parallel-option-failure.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parallel option should match snapshot for errors into the "jest-worker" package whe the "cache" option is "true": errors 1`] = `
Array [
"Error: one.js from Terser
Error: jest-worker failed",
"Error: two.js from Terser
Error: jest-worker failed",
]
`;

exports[`parallel option should match snapshot for errors into the "jest-worker" package whe the "cache" option is "true": warnings 1`] = `Array []`;

exports[`parallel option should match snapshot for errors into the "jest-worker" package: errors 1`] = `
Array [
"Error: one.js from Terser
Expand Down
Loading