Skip to content

Commit d766316

Browse files
committed
doc(samples) add e2e test for 13-mongo-typeorm
see nestjs#1539
1 parent fd880f2 commit d766316

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

sample/13-mongo-typeorm/.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ npm-debug.log
1313
/quick-start
1414

1515
# tests
16-
/test
1716
/coverage
1817
/.nyc_output
1918

2019
# dist
21-
/dist
20+
/dist
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"moduleFileExtensions": [
3+
"js",
4+
"json",
5+
"ts"
6+
],
7+
"rootDir": ".",
8+
"testEnvironment": "node",
9+
"testRegex": ".e2e-spec.ts$",
10+
"transform": {
11+
"^.+\\.(t|j)s$": "ts-jest"
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { INestApplication } from '@nestjs/common';
2+
import { Test } from '@nestjs/testing';
3+
import * as request from 'supertest';
4+
import { ApplicationModule } from '../src/app.module';
5+
6+
describe('Photos (e2e)', () => {
7+
let app: INestApplication;
8+
9+
beforeAll(async () => {
10+
const moduleFixture = await Test.createTestingModule({
11+
imports: [ApplicationModule],
12+
}).compile();
13+
app = moduleFixture.createNestApplication();
14+
await app.init();
15+
});
16+
17+
afterAll(async () => {
18+
if (app) {
19+
await app.close();
20+
}
21+
});
22+
23+
it('should return an empty list of photos', async () => {
24+
await request(app.getHttpServer())
25+
.get('/photo')
26+
.expect(200)
27+
.expect(res => expect(res.body)
28+
.toEqual([]));
29+
});
30+
});

0 commit comments

Comments
 (0)