Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
cache-dependency-path: server/yarn.lock
- run: yarn
- run: yarn test
- run: yarn test:e2e


client-tests:
Expand Down
15 changes: 14 additions & 1 deletion server/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -14,6 +15,12 @@ describe('AppController (e2e)', () => {

app = moduleFixture.createNestApplication();
await app.init();

dataSource = moduleFixture.get<DataSource>(DataSource);
});

afterEach(async () => {
await app.close();
});

it('/ (GET)', () => {
Expand All @@ -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:');
});
});
3 changes: 2 additions & 1 deletion server/test/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"moduleNameMapper": {
"^src/(.*)$": "<rootDir>/src/$1",
"^@shared/(.*)$": "<rootDir>/shared/$1"
}
},
"setupFiles": ["<rootDir>/test/setup-e2e.ts"]
}
3 changes: 3 additions & 0 deletions server/test/setup-e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Set environment variables for E2E tests
process.env.NODE_ENV = 'test';
process.env.JWT_SECRET = 'test-secret';