diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2f34f789..ff1fbaa7 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -48,6 +48,7 @@ jobs: cache-dependency-path: server/yarn.lock - run: yarn - run: yarn test + - run: yarn test:e2e client-tests: diff --git a/server/test/app.e2e-spec.ts b/server/test/app.e2e-spec.ts index 65d668ce..fd834eb6 100644 --- a/server/test/app.e2e-spec.ts +++ b/server/test/app.e2e-spec.ts @@ -1,11 +1,12 @@ -process.env.JWT_SECRET = 'test-secret'; import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; import { AppModule } from 'src/app.module'; +import { DataSource } from 'typeorm'; describe('AppController (e2e)', () => { let app: INestApplication; + let dataSource: DataSource; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ @@ -14,6 +15,12 @@ describe('AppController (e2e)', () => { app = moduleFixture.createNestApplication(); await app.init(); + + dataSource = moduleFixture.get(DataSource); + }); + + afterEach(async () => { + await app.close(); }); it('/ (GET)', () => { @@ -22,4 +29,10 @@ describe('AppController (e2e)', () => { .expect(200) .expect('Hello World!'); }); + + it('should use SQLite in-memory database for E2E tests', () => { + expect(dataSource).toBeDefined(); + expect(dataSource.options.type).toBe('sqlite'); + expect((dataSource.options as any).database).toBe(':memory:'); + }); }); diff --git a/server/test/jest-e2e.json b/server/test/jest-e2e.json index 68798115..915e569a 100644 --- a/server/test/jest-e2e.json +++ b/server/test/jest-e2e.json @@ -10,5 +10,6 @@ "moduleNameMapper": { "^src/(.*)$": "/src/$1", "^@shared/(.*)$": "/shared/$1" - } + }, + "setupFiles": ["/test/setup-e2e.ts"] } diff --git a/server/test/setup-e2e.ts b/server/test/setup-e2e.ts new file mode 100644 index 00000000..8385a2f0 --- /dev/null +++ b/server/test/setup-e2e.ts @@ -0,0 +1,3 @@ +// Set environment variables for E2E tests +process.env.NODE_ENV = 'test'; +process.env.JWT_SECRET = 'test-secret';