import { sveltekit } from '@sveltejs/kit/vite';
const config = {
plugins: [sveltekit()],
test: {
include: ['**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
environment: 'jsdom',
globals: true,
setupFiles: 'src/setupTests.ts'
}
};
export default config;
import '@testing-library/jest-dom/extend-expect';
onMount(() => {
postElementId = crypto.randomUUID();
...
});
TypeError: crypto.randomUUID is not a function
I've got a component that uses the crypto api to create a random id and works as intended, but when I want to test it, everytime I do this error pops up, any help is appreciated!
Just checking, did you:
import crypto from 'node:crypto';
at some point?