Finish switch from Jest to Vitest in API (#16263)

* build:  add vitest and update test scripts

* build: 🔧 add vitest config

* build:  Migrate tests to vitest

Remove jest references from test api test files and replace with vitest equivalents.

Tests: 13 tests are failing.

* build: 🚚 move vite.config.ts to api/src folder

* build: 🔥 remove unused vitest.config from api root

* build:  import vitest modules for tests

* build:  add type conversion for actual object

* Finish switch from Jest to Vitest in API

* Replace some leftovers

* Load "sharp" before tests

* Try with cjs

* Temporary enable verbose reporter

* Try with globalSetup

* Fix path to globalSetup

* Provide default export in globalSetup

* Final clean-up

* Remove @vitest/ui & update vitest to 0.25.0

* Add vitest c8 coverage dependency

* Update vitest to v0.25.1

* Replace unnecessary Vitest workaround

* Rework new tests

* Resolve build errors

Co-authored-by: Dorian C Brown <brown.3794@gmail.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
Pascal Jufer
2022-11-14 22:09:47 +01:00
committed by GitHub
parent 20b8146221
commit c303bdcf10
40 changed files with 416 additions and 392 deletions

View File

@@ -5,14 +5,15 @@ import { ItemsService } from '../../src/services';
import { sqlFieldFormatter, sqlFieldList } from '../__utils__/items-utils';
import { systemSchema, userSchema } from '../__utils__/schemas';
import { cloneDeep } from 'lodash';
import { describe, beforeAll, afterEach, it, expect, vi } from 'vitest';
jest.mock('../../src/database/index', () => {
return { getDatabaseClient: jest.fn().mockReturnValue('postgres') };
vi.mock('../../src/database/index', () => {
return { getDatabaseClient: vi.fn().mockReturnValue('postgres') };
});
jest.requireMock('../../src/database/index');
vi.mock('../../src/database/index');
describe('Integration Tests', () => {
let db: jest.Mocked<Knex>;
let db: Knex;
let tracker: Tracker;
const schemas: Record<string, any> = {
@@ -21,7 +22,7 @@ describe('Integration Tests', () => {
};
beforeAll(async () => {
db = knex({ client: MockClient }) as jest.Mocked<Knex>;
db = knex({ client: MockClient });
tracker = getTracker();
});