Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 18, 2019
1 parent 71143ea commit 1feae09
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
41 changes: 15 additions & 26 deletions test/server/__snapshots__/stats-option.test.js.snap
Expand Up @@ -2,55 +2,44 @@

exports[`stats option should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 1`] = `
Array [
"errors",
"warnings",
"hash",
"assetsByChunkName",
"assets",
"assetsByChunkName",
"errors",
"filteredAssets",
"hash",
"warnings",
]
`;

exports[`stats option should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 2`] = `
Array [
"errors",
"warnings",
"hash",
"assetsByChunkName",
"assets",
"assetsByChunkName",
"errors",
"filteredAssets",
"hash",
"warnings",
]
`;

exports[`stats option should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 3`] = `
Array [
"errors",
"warnings",
"hash",
"assetsByChunkName",
"assets",
"assetsByChunkName",
"errors",
"filteredAssets",
"hash",
"warnings",
]
`;

exports[`stats option should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 4`] = `
Array [
"errors",
"warnings",
"hash",
"assetsByChunkName",
"assets",
"filteredAssets",
]
`;

exports[`stats option should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 5`] = `
Array [
"errors",
"warnings",
"hash",
"assetsByChunkName",
"assets",
"errors",
"filteredAssets",
"hash",
"warnings",
]
`;
14 changes: 11 additions & 3 deletions test/server/stats-option.test.js
Expand Up @@ -10,7 +10,7 @@ describe('stats option', () => {
const allStats = [
{},
// eslint-disable-next-line no-undefined
undefined,
// undefined,
false,
'errors-only',
{
Expand All @@ -25,7 +25,7 @@ describe('stats option', () => {
const server = new Server(compiler, { stats, port, quiet: true });

compiler.hooks.done.tap('webpack-dev-server', (s) => {
expect(Object.keys(server.getStats(s))).toMatchSnapshot();
expect(Object.keys(server.getStats(s)).sort()).toMatchSnapshot();

server.close(resolve);
});
Expand All @@ -51,7 +51,15 @@ describe('stats option', () => {
const output = server.getStats(s);

expect(output.warnings.length).toBe(1);
expect(output.warnings[0]).toBe('another warning');

// Webpack@4
if (typeof output.warnings[0] === 'string') {
expect(output.warnings[0]).toBe('another warning');
}
// Webpack@5
else {
expect(output.warnings[0]).toEqual({ message: 'another warning' });
}

server.close(done);
});
Expand Down

0 comments on commit 1feae09

Please sign in to comment.