Uuid: ESM Problems with Jest@26 and Node.js 14.x

Created on 14 May 2020  ยท  3Comments  ยท  Source: uuidjs/uuid

Hi, I'm using jest to test my project.
Trying to test a file where I import uuid results with an error:

 โ— Test suite failed to run

    SyntaxError: The requested module 'uuid' does not provide an export named 'v1'

          at async Promise.all (index 0)
      at jasmine2 (node_modules/jest-jasmine2/build/index.js:228:5)

I saw @dps910 comment and I guess it's something similar.
I'm using UUID@8, node@14 and Jest@26 (and it's freshly-supported esm modules implementation).

Jest command:
node --experimental-vm-modules .\node_modules\jest\bin\jest.js
The file that I'm testing imports uuid like you suggested:

import { v1 as uuidv1 } from 'uuid';
uuidv1();

It fails only when I'm testing though.

_Originally posted by @Tzahile in https://github.com/uuidjs/uuid/issues/245#issuecomment-628650062_

waiting-for-upstream

Most helpful comment

All 3 comments

Looks like "exports" is not supported yet.
https://github.com/facebook/jest/issues/9430#issuecomment-623941616

@Tzahile as pointed out by @TrySound, ESM support in jest is not complete yet. I think you will have to wait for ESM support in jest to be finished before you can use it with this library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danactive picture danactive  ยท  3Comments

ctavan picture ctavan  ยท  5Comments

wesleytodd picture wesleytodd  ยท  10Comments

mfbx9da4 picture mfbx9da4  ยท  4Comments

lnogueir picture lnogueir  ยท  5Comments