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 8f21f10
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')) {

Check failure on line 16 in setupTest.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected space(s) after "if"

Check failure on line 16 in setupTest.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected space(s) after "if"
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 @@ -5,6 +5,16 @@ import { fileURLToPath } from 'url';
import fs from 'fs/promises';

export default defineConfig({
test: {
environment: 'happy-dom',
exclude: ['node_modules'],
fileParallelism: false,
maxConcurrency: 1,
globals: true,

Check failure on line 13 in vitest.config.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'globals' should be before 'maxConcurrency'

Check failure on line 13 in vitest.config.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'globals' should be before 'maxConcurrency'
include: ['**/*.test.js', '**/*.test.jsx'],
name: 'unit',
setupFiles: ['./setupTest.js'],
},
esbuild: {

Check failure on line 18 in vitest.config.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'esbuild' should be before 'test'

Check failure on line 18 in vitest.config.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'esbuild' should be before 'test'
exclude: [],
include: /(src|__tests__)\/.*\.jsx?$/,
Expand Down
29 changes: 0 additions & 29 deletions vitest.workspace.ts

This file was deleted.

0 comments on commit 8f21f10

Please sign in to comment.