From c8b2d1b44a9f9376eee7bc6c26e84bd7f5c03354 Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Tue, 10 Oct 2023 13:39:54 -0700 Subject: [PATCH] (test only) Integration tests: remove flatMap polyfill (#56546) This has been supported since Node 11. Remove this from our integration tests. Test Plan: CI Closes WEB-1735 --- .../build-output/test/index.test.js | 1 - .../css/test/basic-global-support.test.js | 1 - .../css/test/css-and-styled-jsx.test.js | 1 - .../css/test/css-compilation.test.js | 1 - test/integration/css/test/css-modules.test.js | 1 - .../css/test/css-rendering.test.js | 1 - .../css/test/dev-css-handling.test.js | 1 - .../css/test/valid-invalid-css.test.js | 1 - .../fallback-modules/test/index.test.js | 1 - .../scss/test/basic-global-support.test.js | 1 - test/integration/scss/test/basic-scss.test.js | 1 - .../scss/test/css-and-styled-jsx.test.js | 1 - .../scss/test/dev-css-handling.test.js | 1 - .../scss/test/scss-loader-handling.test.js | 1 - .../scss/test/valid-invalid-scss.test.js | 1 - test/lib/flat-map-polyfill.js | 37 ------------------- 16 files changed, 52 deletions(-) delete mode 100644 test/lib/flat-map-polyfill.js diff --git a/test/integration/build-output/test/index.test.js b/test/integration/build-output/test/index.test.js index c33bae18a76c2..6047f4728708e 100644 --- a/test/integration/build-output/test/index.test.js +++ b/test/integration/build-output/test/index.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { nextBuild, File } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/css/test/basic-global-support.test.js b/test/integration/css/test/basic-global-support.test.js index a2f9dee9d5380..69bac5f370770 100644 --- a/test/integration/css/test/basic-global-support.test.js +++ b/test/integration/css/test/basic-global-support.test.js @@ -1,5 +1,4 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/css/test/css-and-styled-jsx.test.js b/test/integration/css/test/css-and-styled-jsx.test.js index 454f2c45695ff..c2959aab05aa4 100644 --- a/test/integration/css/test/css-and-styled-jsx.test.js +++ b/test/integration/css/test/css-and-styled-jsx.test.js @@ -1,5 +1,4 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { findPort, diff --git a/test/integration/css/test/css-compilation.test.js b/test/integration/css/test/css-compilation.test.js index 34ea5f1ee779f..eafdac53885db 100644 --- a/test/integration/css/test/css-compilation.test.js +++ b/test/integration/css/test/css-compilation.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ import cheerio from 'cheerio' -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { findPort, diff --git a/test/integration/css/test/css-modules.test.js b/test/integration/css/test/css-modules.test.js index 277ee19987703..d95264dfb45b5 100644 --- a/test/integration/css/test/css-modules.test.js +++ b/test/integration/css/test/css-modules.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ import cheerio from 'cheerio' -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { check, diff --git a/test/integration/css/test/css-rendering.test.js b/test/integration/css/test/css-rendering.test.js index b89b16791384c..aedbb1283cf71 100644 --- a/test/integration/css/test/css-rendering.test.js +++ b/test/integration/css/test/css-rendering.test.js @@ -1,5 +1,4 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { pathExists, readFile, readJSON, remove } from 'fs-extra' import { check, diff --git a/test/integration/css/test/dev-css-handling.test.js b/test/integration/css/test/dev-css-handling.test.js index d849fb7556367..51960221a7352 100644 --- a/test/integration/css/test/dev-css-handling.test.js +++ b/test/integration/css/test/dev-css-handling.test.js @@ -1,5 +1,4 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { check, diff --git a/test/integration/css/test/valid-invalid-css.test.js b/test/integration/css/test/valid-invalid-css.test.js index 9e1240ce57d6d..0dc725c4ff7ec 100644 --- a/test/integration/css/test/valid-invalid-css.test.js +++ b/test/integration/css/test/valid-invalid-css.test.js @@ -1,5 +1,4 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/fallback-modules/test/index.test.js b/test/integration/fallback-modules/test/index.test.js index 41c7c1bd47d9f..f9550c3b5444d 100644 --- a/test/integration/fallback-modules/test/index.test.js +++ b/test/integration/fallback-modules/test/index.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/scss/test/basic-global-support.test.js b/test/integration/scss/test/basic-global-support.test.js index c73ee38686cf1..3d1a6ca69a078 100644 --- a/test/integration/scss/test/basic-global-support.test.js +++ b/test/integration/scss/test/basic-global-support.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/scss/test/basic-scss.test.js b/test/integration/scss/test/basic-scss.test.js index d1ed47970b63a..427629af36b05 100644 --- a/test/integration/scss/test/basic-scss.test.js +++ b/test/integration/scss/test/basic-scss.test.js @@ -1,7 +1,6 @@ /* eslint-env jest */ import cheerio from 'cheerio' -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { File, diff --git a/test/integration/scss/test/css-and-styled-jsx.test.js b/test/integration/scss/test/css-and-styled-jsx.test.js index 234b07060221c..7c051c7fa79c4 100644 --- a/test/integration/scss/test/css-and-styled-jsx.test.js +++ b/test/integration/scss/test/css-and-styled-jsx.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { findPort, diff --git a/test/integration/scss/test/dev-css-handling.test.js b/test/integration/scss/test/dev-css-handling.test.js index fb9f52931f4f2..1aaadff62d96c 100644 --- a/test/integration/scss/test/dev-css-handling.test.js +++ b/test/integration/scss/test/dev-css-handling.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { File, findPort, killApp, launchApp, waitFor } from 'next-test-utils' import webdriver from 'next-webdriver' diff --git a/test/integration/scss/test/scss-loader-handling.test.js b/test/integration/scss/test/scss-loader-handling.test.js index 27728a2286e61..c6b4e5be51063 100644 --- a/test/integration/scss/test/scss-loader-handling.test.js +++ b/test/integration/scss/test/scss-loader-handling.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { readdir, readFile, remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/integration/scss/test/valid-invalid-scss.test.js b/test/integration/scss/test/valid-invalid-scss.test.js index 49a0472a31490..7d7dfab268df5 100644 --- a/test/integration/scss/test/valid-invalid-scss.test.js +++ b/test/integration/scss/test/valid-invalid-scss.test.js @@ -1,6 +1,5 @@ /* eslint-env jest */ -import 'flat-map-polyfill' import { remove } from 'fs-extra' import { nextBuild } from 'next-test-utils' import { join } from 'path' diff --git a/test/lib/flat-map-polyfill.js b/test/lib/flat-map-polyfill.js deleted file mode 100644 index b9ad706cfee17..0000000000000 --- a/test/lib/flat-map-polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -if (!Array.prototype.flat) { - // eslint-disable-next-line no-extend-native - Object.defineProperty(Array.prototype, 'flat', { - configurable: true, - value: function flat() { - var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]) - - return depth - ? Array.prototype.reduce.call( - this, - function (acc, cur) { - if (Array.isArray(cur)) { - acc.push.apply(acc, flat.call(cur, depth - 1)) - } else { - acc.push(cur) - } - - return acc - }, - [] - ) - : Array.prototype.slice.call(this) - }, - writable: true, - }) -} - -if (!Array.prototype.flatMap) { - // eslint-disable-next-line no-extend-native - Object.defineProperty(Array.prototype, 'flatMap', { - configurable: true, - value: function flatMap() { - return Array.prototype.map.apply(this, arguments).flat() - }, - writable: true, - }) -}