Skip to content

Commit

Permalink
Re-unify the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 27, 2024
1 parent 3f91bc3 commit 91ca96e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 35 deletions.
12 changes: 12 additions & 0 deletions setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import '@testing-library/jest-dom';
import { vi } from 'vitest';
import { setupIntersectionMocking } from 'react-intersection-observer/test-utils';
import i18next from 'i18next';
import createFetchMock from 'vitest-fetch-mock';
import en from './src/locales/en/translation.json';

// vitest doesn't set a default
window.origin = 'http://localhost';

vi.setConfig({ testTimeout: 10_000 });
const fetchMocker = createFetchMock(vi);

// changes default behavior of fetchMock to use the real 'fetch' implementation and not mock responses
beforeEach((context) => {
if (context.task.file.name.includes('/integration')) {
fetchMocker.disableMocks();
} else {
// sets globalThis.fetch and globalThis.fetchMock to our mocked version
fetchMocker.enableMocks();
}
});

/** */
class Path2D {
Expand Down
6 changes: 0 additions & 6 deletions setupUnitTest.js

This file was deleted.

10 changes: 10 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ export default defineConfig({
'@tests': fileURLToPath(new URL('./__tests__', import.meta.url)),
},
},
test: {
environment: 'happy-dom',
exclude: ['node_modules'],
fileParallelism: false,
globals: true,
include: ['**/*.test.js', '**/*.test.jsx'],
maxConcurrency: 1,
name: 'unit',
setupFiles: ['./setupTest.js'],
},
});
29 changes: 0 additions & 29 deletions vitest.workspace.ts

This file was deleted.

0 comments on commit 91ca96e

Please sign in to comment.