feat: Use vitest instead of jest for ESM compatibility

This commit is contained in:
Faruk AYDIN
2024-01-12 14:07:59 +01:00
parent 911159a14f
commit af9ceac0b4
19 changed files with 655 additions and 66 deletions

View File

@@ -1,6 +1,8 @@
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const testEnvFile = path.resolve(__dirname, '../../.env.test');
if (!fs.existsSync(testEnvFile)) {

View File

@@ -1,6 +1,6 @@
import { Model } from 'objection';
import { client as knex } from '../../src/config/database';
import logger from '../../src/helpers/logger';
import { client as knex } from '../../src/config/database.js';
import logger from '../../src/helpers/logger.js';
global.beforeAll(async () => {
global.knex = null;
@@ -22,8 +22,8 @@ global.afterEach(async () => {
await global.knex.rollback();
Model.knex(knex);
jest.restoreAllMocks();
jest.clearAllMocks();
// jest.restoreAllMocks();
// jest.clearAllMocks();
});
global.afterAll(async () => {

View File

@@ -1,5 +0,0 @@
const exitProcess = (): void => {
process.exit(0);
};
export default exitProcess;

View File

@@ -1,8 +1,8 @@
import './check-env-file';
import { createDatabaseAndUser } from '../../bin/database/utils';
import { client as knex } from '../../src/config/database';
import logger from '../../src/helpers/logger';
import appConfig from '../../src/config/app';
import './check-env-file.js';
import { createDatabaseAndUser } from '../../bin/database/utils.js';
import { client as knex } from '../../src/config/database.js';
import logger from '../../src/helpers/logger.js';
import appConfig from '../../src/config/app.js';
const createAndMigrateDatabase = async () => {
if (!appConfig.CI) {