Skip to content

Commit

Permalink
🤡 [#724] Fix broken mocks by lazy loading the Formio module
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Jan 3, 2025
1 parent 9fc82a9 commit 3fa646d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/vitest.setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import '@testing-library/jest-dom';
import {Formio} from 'react-formio';

import mswServer from 'api-mocks/msw-server';
// Use our custom components
import OpenFormsModule from 'formio/module';

beforeAll(() => {
beforeAll(async () => {
// set up HTTP mocks
mswServer.listen({
onUnhandledRequest: 'error',
});

// ensure our custom Formio module is registered
Formio.use(OpenFormsModule);
// Use our custom components by registering the custom Formio module.
// The import must be dynamic, otherwise vi.mock fails in tests...
const OpenFormsModule = await import('formio/module');
Formio.use(OpenFormsModule.default);
});
afterEach(() => mswServer.resetHandlers());
afterAll(() => mswServer.close());

0 comments on commit 3fa646d

Please sign in to comment.