load-with-esm.ts 780 B

123456789101112131415161718192021
  1. import { test } from 'tap';
  2. const importESM : (specifier : string) => Promise<any> =
  3. // eslint-disable-next-line no-eval
  4. eval('(specifier) => import(specifier)');
  5. test('Piscina is default export', {}, async ({ equal }) => {
  6. equal((await importESM('piscina')).default, require('../'));
  7. });
  8. test('Exports match own property names', {}, async ({ strictSame }) => {
  9. // Check that version, workerData, etc. are re-exported.
  10. const exported = new Set(Object.getOwnPropertyNames(await importESM('piscina')));
  11. const required = new Set(Object.getOwnPropertyNames(require('../')));
  12. // Remove constructor properties + default export.
  13. for (const k of ['prototype', 'length', 'name']) required.delete(k);
  14. exported.delete('default');
  15. strictSame(exported, required);
  16. });