Skip to content

Commit

Permalink
chore(): remplace Jest par Vitest (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaubert authored Dec 16, 2024
1 parent fffc37c commit 2a2c19a
Show file tree
Hide file tree
Showing 64 changed files with 539 additions and 2,979 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DATABASE_ENV=Dummy
DATABASE_URL=postgres://postgres:zlv@localhost/maestro
DATABASE_URL_TEST=postgres://postgres:zlv@localhost/test_maestro

AUTH_SECRET=secret

Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:
env:
AUTH_SECRET: abcd1234
DATABASE_URL: postgres://postgres:postgres@localhost:5432/maestro
DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/maestro
NODE_ENV: production
S3_ENDPOINT: s3
S3_REGION: region
Expand All @@ -79,12 +78,8 @@ jobs:
# env:
# AUTH_SECRET: abcd1234
# DATABASE_URL: postgres://postgres:postgres@localhost:5432/maestro
# DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/maestro
- name: Server integration tests
run: npm run test -- --test-timeout=30000
- name: Server tests
run: npm run test
env:
AUTH_SECRET: abcd1234
DATABASE_URL: postgres://postgres:postgres@localhost:5432/maestro
DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/maestro
- name: Server unit tests
run: npm run test:unit
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ AUTH_SECRET
AUTH_EXPIRES_IN
DATABASE_ENV
DATABASE_URL
DATABASE_URL_TEST
MAILER_PROVIDER
MAILER_HOST
MAILER_PORT
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/001-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { fakerFR } from '@faker-js/faker';
import bcrypt from 'bcryptjs';
import { v4 as uuidv4 } from 'uuid';
import { Users } from '../../../server/repositories/userRepository';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

exports.seed = async function () {
await Users().insert([
{
id: uuidv4(),
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/002-laboratories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { fakerFR } from '@faker-js/faker';
import { v4 as uuidv4 } from 'uuid';
import { Laboratories } from '../../../server/repositories/laboratoryRepository';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

export const SCL34Id = uuidv4();
export const LDA66Id = uuidv4();
Expand All @@ -22,7 +24,9 @@ export const DummyLaboratoryIds = [
FYTId,
];

exports.seed = async function () {
exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

await Laboratories().insert([
{
id: SCL34Id,
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/003-programming-plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { v4 as uuidv4 } from 'uuid';
import { ProgrammingPlans } from '../../../server/repositories/programmingPlanRepository';
import userRepository from '../../../server/repositories/userRepository';
import { genProgrammingPlan } from '../../../shared/test/programmingPlanFixtures';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

export const validatedProgrammingPlanId = uuidv4();

exports.seed = async function () {
exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

const user = await userRepository.findOne('[email protected]');

if (!user) {
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/004-prescriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { genPrescription } from '../../../shared/test/prescriptionFixtures';
import { oneOf } from '../../../shared/test/testFixtures';
import { validatedProgrammingPlanId } from '../dummy/003-programming-plans';
import { DummyLaboratoryIds } from './002-laboratories';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

export const abricotsEtSimilaires = genPrescription({
id: '02b1d919-f5e7-4d67-afa6-dc8e7e8f3687',
Expand Down Expand Up @@ -248,7 +250,9 @@ export const graineDeTournesol2 = genPrescription({
'STADE9',
],
});
exports.seed = async function () {
exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

const validatedProgrammingPlan = await ProgrammingPlans()
.where({ status: 'Validated' })
.first();
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/005-companies.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Companies } from '../../../server/repositories/companyRepository';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

exports.seed = async function () {
await Companies().insert([
{
siret: '77560611400061',
Expand Down
7 changes: 5 additions & 2 deletions database/seeds/dummy/006-samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Region, Regions } from '../../../shared/referential/Region';
import { Sample } from '../../../shared/schema/Sample/Sample';
import { genCreatedSample } from '../../../shared/test/sampleFixtures';
import { oneOf } from '../../../shared/test/testFixtures';
import { Sampler1Fixture } from '../test/001-users';
import { Sampler1Fixture } from '../../../server/test/seed/001-users';
import { DummyLaboratoryIds } from './002-laboratories';
import {
abricotsEtSimilaires,
Expand All @@ -22,8 +22,11 @@ import {
lentilles,
oignons
} from './004-prescriptions';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';
exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

exports.seed = async function () {
const validatedProgrammingPlan = await ProgrammingPlans()
.where({ status: 'Validated' })
.first();
Expand Down
7 changes: 5 additions & 2 deletions database/seeds/dummy/007-substances.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import db from '../../../server/repositories/db';
import db, { setKnexInstance } from '../../../server/repositories/db';
import { Substance } from '../../../shared/schema/Substance/Substance';
import { Knex } from 'knex';

exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

exports.seed = async function () {
const genSubstance = (code: string, label: string): Substance => ({
code,
label,
Expand Down
6 changes: 5 additions & 1 deletion database/seeds/dummy/008-substance-analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ import {
poires,
rizEtSimilaires,
} from './004-prescriptions';
import { Knex } from 'knex';
import { setKnexInstance } from '../../../server/repositories/db';

exports.seed = async function (knex: Knex) {
setKnexInstance(knex)

exports.seed = async function () {
const genSubstanceAnalysis = (
prescriptionId: string,
analysisKind: AnalysisKind,
Expand Down
30 changes: 0 additions & 30 deletions jest.config.ts

This file was deleted.

10 changes: 10 additions & 0 deletions knexfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import knexStringcase from 'knex-stringcase';
import { Knex } from 'knex';

const config: Knex.Config = {
client: 'pg',
acquireConnectionTimeout: 10000,
...knexStringcase()
};

export default config
Loading

0 comments on commit 2a2c19a

Please sign in to comment.