vite.config.ts
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;
src/setupTests.ts
import '@testing-library/jest-dom/extend-expect';
MyComponent.svelte
onMount(() => {
postElementId = crypto.randomUUID();
...
});
错误
TypeError: crypto.randomUUID is not a function
我有一个组件,它使用密码api创建随机id并按预期工作,但是当我想测试它时,每次我做这个错误都会弹出,任何帮助都会被感谢!
!
发布于 2022-09-26 01:05:05
只是问问,你有没有:
import crypto from 'node:crypto';
在某个时候?
https://stackoverflow.com/questions/73831370
复制相似问题