Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 5, 2022
1 parent ed05beb commit 87e1eed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -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",
Expand Down
19 changes: 19 additions & 0 deletions 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'));

0 comments on commit 87e1eed

Please sign in to comment.