prototype working state

This commit is contained in:
echo committed 2025-04-09 23:25:31 +02:00
1 parent fdae53f82f
commit eada8b3eb1
86 files changed
+22240

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { App } from 'supertest/types';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication<App>;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
+36
View File
@@ -0,0 +1,36 @@
import { Test, TestingModule } from '@nestjs/testing';
import * as request from 'supertest';
import { INestApplication } from '@nestjs/common';
import { AppModule } from '../src/app.module';
describe('AuthController (e2e)', () => {
let app: INestApplication;
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
afterAll(async () => {
await app.close();
});
it('/auth/login (POST) - success', () => {
return request(app.getHttpServer())
.post('/auth/login')
.send({ username: 'test', password: 'test' })
.expect(201)
.expect({ userId: 1, username: 'test' });
});
it('/auth/login (POST) - failure', () => {
return request(app.getHttpServer())
.post('/auth/login')
.send({ username: 'wrong', password: 'wrong' })
.expect(401);
});
});
+9
View File
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}