Closed
Description
I trying upgrade nanoid from 2.x to 3.x in CRA environment
The export value from nanoid
is always undefined
And i got error when running below jest test
import { nanoid } from 'nanoid';
it('Should work', () => {
console.log('nanoid is ', nanoid);
const genId = nanoid();
expect(() => genId()).not.toThrow();
});
Console message
console.log src/services/spotify/auth/__tests__/authorize.test.ts:14
nanoid is undefined
TypeError: (0 , _nanoid.nanoid) is not a function
Also i try below test
import * as nanoid from 'nanoid';
it('Should work', () => {
console.log('nanoid is ', nanoid);
const genId = nanoid.nanoid();
expect(() => genId()).not.toThrow();
});
Console message
console.log src/services/spotify/auth/__tests__/authorize.test.ts:14
nanoid is { default: 'index.cjs' }
TypeError: nanoid.nanoid is not a function
Metadata
Metadata
Assignees
Labels
No labels