Skip to content

Commit

Permalink
try not rendering app, will the worker get initialized?
Browse files Browse the repository at this point in the history
  • Loading branch information
alan2207 committed Apr 29, 2024
1 parent ad5335a commit 1fee53c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import * as React from 'react';
import { createRoot } from 'react-dom/client';

import './index.css';
import App from './App';
// import App from './App';
import { initMocks } from './test/server';

const root = createRoot(document.getElementById('root') as HTMLElement);

initMocks().then(() => {
console.log('Mocks initialized');
root.render(
<React.StrictMode>
<App />
<div>Hello World</div>
</React.StrictMode>
);
});
3 changes: 2 additions & 1 deletion src/test/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const initMocks = async () => {
if (import.meta.env.VITE_APP_API_MOCKING === 'true') {
console.log('API mocking enabled');
const { worker } = await import('./browser');

console.log('Starting worker');
return worker.start();
}
};

0 comments on commit 1fee53c

Please sign in to comment.