From e18541bfe09651eac00cddfffa858f0cce6cc867 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Tue, 13 Sep 2022 02:08:52 +0700 Subject: [PATCH] add some tests --- package.json | 5 +++-- tests/builder/builder.mjs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/builder/builder.mjs diff --git a/package.json b/package.json index d47c592bab21..c37356698286 100644 --- a/package.json +++ b/package.json @@ -137,14 +137,15 @@ "test-entries-basic": "zx tests/commonjs.mjs", "test-entries-content": "zx tests/commonjs-entries-content.mjs", "test-entries-standalone": "run-s init test-entries", + "test-builder": "zx tests/builder/builder.mjs", "test-compat-tools": "run-p test-compat-tool test-compat-targets-parser test-compat-get-modules-list-for-target-version", "test-compat-tool": "zx tests/compat-tools/compat.mjs", "test-compat-targets-parser": "zx tests/compat-tools/targets-parser.mjs", "test-compat-get-modules-list-for-target-version": "zx tests/compat-tools/get-modules-list-for-target-version.mjs", "test262": "test262-harness -t \"$(node -pe 'os.cpus().length')\" --host-args='--unhandled-rejections=none' --preprocessor=./tests/test262.js --prelude=./packages/core-js-bundle/index.js --test262-dir=node_modules/test262 'node_modules/test262/test/built-ins/**/*.js'", - "test": "run-s init test-lint bundle test-unit test-promises test-observables test-entries test-compat-tools check", + "test": "run-s init test-lint bundle test-unit test-promises test-observables test-entries test-compat-tools test-builder check", "ci-karma": "run-s init bundle test-unit-karma", - "ci-tests": "run-s init bundle test-unit-node test-promises test-observables test-entries test-compat-tools", + "ci-tests": "run-s init bundle test-unit-node test-promises test-observables test-entries test-compat-tools test-builder", "clean-dependencies": "node scripts/clean-dependencies.mjs", "refresh": "npm run clean-dependencies && npm it", "downloads": "zx scripts/downloads-by-versions.mjs", diff --git a/tests/builder/builder.mjs b/tests/builder/builder.mjs new file mode 100644 index 000000000000..61fc5c8aadf7 --- /dev/null +++ b/tests/builder/builder.mjs @@ -0,0 +1,19 @@ +import { ok } from 'assert/strict'; +import builder from 'core-js-builder'; + +const polyfills = await builder({ + modules: 'core-js/actual', + exclude: [/group-by/, 'esnext.typed-array.to-spliced'], + targets: { node: 16 }, + format: 'esm', +}); + +ok(polyfills.includes("import 'core-js/modules/es.error.cause.js';"), 'actual node 16 #1'); +ok(polyfills.includes("import 'core-js/modules/es.array.push.js';"), 'actual node 16 #2'); +ok(polyfills.includes("import 'core-js/modules/esnext.array.group.js';"), 'actual node 16 #3'); +ok(polyfills.includes("import 'core-js/modules/web.structured-clone.js';"), 'actual node 16 #4'); +ok(!polyfills.includes("import 'core-js/modules/es.weak-set.js';"), 'actual node 16 #5'); +ok(!polyfills.includes("import 'core-js/modules/esnext.weak-set.from.js';"), 'actual node 16 #6'); +ok(!polyfills.includes("import 'core-js/modules/esnext.array.group-by.js';"), 'actual node 16 #7'); + +echo(chalk.green('builder tested'));