From fd73d0a172e4f415a1393bf03cd764d385593e91 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Wed, 27 Feb 2019 12:01:33 +1100 Subject: [PATCH] test: Fail tests on browser warnings and errors --- .../custom-src-paths.test.js.snap | 4 -- .../__snapshots__/library-build.test.js.snap | 2 - .../multiple-routes.test.js.snap | 6 --- .../__snapshots__/public-path.test.js.snap | 2 - .../react-css-modules.test.js.snap | 2 - .../ssr-hello-world.test.js.snap | 6 --- .../typescript-css-modules.test.js.snap | 6 --- test/utils/appSnapshot.js | 14 +++---- yarn.lock | 38 ++----------------- 9 files changed, 9 insertions(+), 71 deletions(-) diff --git a/test/test-cases/custom-src-paths/__snapshots__/custom-src-paths.test.js.snap b/test/test-cases/custom-src-paths/__snapshots__/custom-src-paths.test.js.snap index 2e4f852a2..14d0eb85a 100644 --- a/test/test-cases/custom-src-paths/__snapshots__/custom-src-paths.test.js.snap +++ b/test/test-cases/custom-src-paths/__snapshots__/custom-src-paths.test.js.snap @@ -62,8 +62,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`custom-src-paths build should generate the expected files 1`] = ` @@ -190,6 +188,4 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/test-cases/library-build/__snapshots__/library-build.test.js.snap b/test/test-cases/library-build/__snapshots__/library-build.test.js.snap index b8c0f5cee..87d177529 100644 --- a/test/test-cases/library-build/__snapshots__/library-build.test.js.snap +++ b/test/test-cases/library-build/__snapshots__/library-build.test.js.snap @@ -46,6 +46,4 @@ POST HYDRATE DIFFS: -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/test-cases/multiple-routes/__snapshots__/multiple-routes.test.js.snap b/test/test-cases/multiple-routes/__snapshots__/multiple-routes.test.js.snap index 9d126c5bc..adc7ccc56 100644 --- a/test/test-cases/multiple-routes/__snapshots__/multiple-routes.test.js.snap +++ b/test/test-cases/multiple-routes/__snapshots__/multiple-routes.test.js.snap @@ -82,8 +82,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`multiple-routes build should generate the expected files 1`] = ` @@ -554,8 +552,6 @@ POST HYDRATE DIFFS: Some special async content -WARNINGS: Array [] -ERRORS: Array [] `; exports[`multiple-routes start should render home page correctly 1`] = ` @@ -632,6 +628,4 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/test-cases/public-path/__snapshots__/public-path.test.js.snap b/test/test-cases/public-path/__snapshots__/public-path.test.js.snap index 02bc2cb84..817f4da2d 100644 --- a/test/test-cases/public-path/__snapshots__/public-path.test.js.snap +++ b/test/test-cases/public-path/__snapshots__/public-path.test.js.snap @@ -59,6 +59,4 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/test-cases/react-css-modules/__snapshots__/react-css-modules.test.js.snap b/test/test-cases/react-css-modules/__snapshots__/react-css-modules.test.js.snap index 9dc4f38b7..e9c926387 100644 --- a/test/test-cases/react-css-modules/__snapshots__/react-css-modules.test.js.snap +++ b/test/test-cases/react-css-modules/__snapshots__/react-css-modules.test.js.snap @@ -73,8 +73,6 @@ POST HYDRATE DIFFS: -WARNINGS: Array [] -ERRORS: Array [] `; exports[`react-css-modules should generate the expected files 1`] = ` diff --git a/test/test-cases/ssr-hello-world/__snapshots__/ssr-hello-world.test.js.snap b/test/test-cases/ssr-hello-world/__snapshots__/ssr-hello-world.test.js.snap index 8341d3db4..e05bbdda0 100644 --- a/test/test-cases/ssr-hello-world/__snapshots__/ssr-hello-world.test.js.snap +++ b/test/test-cases/ssr-hello-world/__snapshots__/ssr-hello-world.test.js.snap @@ -68,8 +68,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`ssr-hello-world build default port should generate a production server based on config 1`] = ` @@ -140,8 +138,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`ssr-hello-world start should start a development server 1`] = ` @@ -212,6 +208,4 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/test-cases/typescript-css-modules/__snapshots__/typescript-css-modules.test.js.snap b/test/test-cases/typescript-css-modules/__snapshots__/typescript-css-modules.test.js.snap index ee65d8678..7374c6c50 100644 --- a/test/test-cases/typescript-css-modules/__snapshots__/typescript-css-modules.test.js.snap +++ b/test/test-cases/typescript-css-modules/__snapshots__/typescript-css-modules.test.js.snap @@ -70,8 +70,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`typescript-css-modules build should generate the expected files 1`] = ` @@ -247,8 +245,6 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; exports[`typescript-css-modules build-ssr should generate the expected files 1`] = ` @@ -351,6 +347,4 @@ SOURCE HTML: POST HYDRATE DIFFS: NO DIFF -WARNINGS: Array [] -ERRORS: Array [] `; diff --git a/test/utils/appSnapshot.js b/test/utils/appSnapshot.js index e696f7eaa..936644325 100644 --- a/test/utils/appSnapshot.js +++ b/test/utils/appSnapshot.js @@ -15,10 +15,7 @@ const cssSnapshotSerializer = { }; const appSnapshotSerializer = { - print: ( - { sourceHtml, clientRenderContent, warnings, errors }, - serializer - ) => { + print: ({ sourceHtml, clientRenderContent }, serializer) => { const serializedSouceHtml = serializer(sourceHtml); const serializedClientRenderContent = serializer(clientRenderContent); @@ -29,9 +26,7 @@ const appSnapshotSerializer = { const snapshotItems = [ `SOURCE HTML: ${serializedSouceHtml}`, - `POST HYDRATE DIFFS: ${htmlDiff ? `\n${htmlDiff}` : 'NO DIFF'}`, - `WARNINGS: ${serializer(warnings)}`, - `ERRORS: ${serializer(errors)}` + `POST HYDRATE DIFFS: ${htmlDiff ? `\n${htmlDiff}` : 'NO DIFF'}` ]; return snapshotItems.join('\n'); @@ -66,7 +61,10 @@ const getAppSnapshot = async url => { const sourceHtml = await response.text(); const clientRenderContent = await page.content(); - return { sourceHtml, clientRenderContent, warnings, errors }; + expect(warnings).toEqual([]); + expect(errors).toEqual([]); + + return { sourceHtml, clientRenderContent }; }; module.exports = { diff --git a/yarn.lock b/yarn.lock index dec0e2839..26516516f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4721,7 +4721,7 @@ debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "^2.1.1" -debuglog@*, debuglog@^1.0.1: +debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= @@ -7312,7 +7312,7 @@ import-local@^2.0.0: pkg-dir "^3.0.0" resolve-cwd "^2.0.0" -imurmurhash@*, imurmurhash@^0.1.4: +imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= @@ -8965,11 +8965,6 @@ lockfile@^1.0.4: dependencies: signal-exit "^3.0.2" -lodash._baseindexof@*: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" - integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw= - lodash._baseuniq@~4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" @@ -8978,33 +8973,11 @@ lodash._baseuniq@~4.6.0: lodash._createset "~4.0.0" lodash._root "~3.0.0" -lodash._bindcallback@*: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" - integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4= - -lodash._cacheindexof@*: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" - integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI= - -lodash._createcache@*: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" - integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM= - dependencies: - lodash._getnative "^3.0.0" - lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= -lodash._getnative@*, lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= - lodash._reinterpolate@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" @@ -9060,11 +9033,6 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.restparam@*: - version "3.6.1" - resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" - integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= - lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" @@ -12195,7 +12163,7 @@ readable-stream@~1.1.10: isarray "0.0.1" string_decoder "~0.10.x" -readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0: +readdir-scoped-modules@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747" integrity sha1-n6+jfShr5dksuuve4DDcm19AZ0c=