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_
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.
FWIW, tracking issue: https://github.com/facebook/jest/issues/9771
Most helpful comment
FWIW, tracking issue: https://github.com/facebook/jest/issues/9771