Add targeted Vitest coverage
This commit is contained in:
1 parent
e3a6c40e14
commit
5bdf20a829
6 files changed
+303
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, test, vi, beforeEach } from 'vitest';
|
||||
|
||||
describe('main entry point', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
vi.clearAllMocks();
|
||||
document.body.innerHTML = '<div id="root"></div>';
|
||||
});
|
||||
|
||||
test('renders app when root element exists', async () => {
|
||||
const render = vi.fn();
|
||||
vi.mock('react-dom/client', () => ({ createRoot: () => ({ render }) }));
|
||||
|
||||
await import('../src/main');
|
||||
|
||||
expect(render).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('throws when root element is missing', async () => {
|
||||
document.body.innerHTML = '';
|
||||
vi.mock('react-dom/client', () => ({ createRoot: () => ({ render: vi.fn() }) }));
|
||||
|
||||
await expect(import('../src/main')).rejects.toThrow('Root element not found');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user