Merge pull request #15 from alsoicode/master

Update Sample Project with Test
This commit is contained in:
Kamil Myśliwiec 2018-03-26 19:35:56 +02:00 committed by GitHub
commit 3229d43b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3989 additions and 5 deletions

View File

@ -10,6 +10,7 @@
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p> <p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center"> <p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a> <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a> <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a> <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a> <a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
@ -41,11 +42,16 @@ $ npm install
$ npm run start $ npm run start
``` ```
## Test
```
$ npm run test
```
## Support ## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest). Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest).
## Stay in touch ## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)

View File

@ -7,7 +7,8 @@
"start": "node index.js", "start": "node index.js",
"start:watch": "nodemon", "start:watch": "nodemon",
"prestart:prod": "tsc", "prestart:prod": "tsc",
"start:prod": "node dist/main.js" "start:prod": "node dist/server.js",
"test": "jest"
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "^4.5.9", "@nestjs/common": "^4.5.9",
@ -20,10 +21,27 @@
"typescript": "^2.6.2" "typescript": "^2.6.2"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.0.39",
"@types/jest": "^21.1.8",
"@types/node": "^9.3.0", "@types/node": "^9.3.0",
"@types/supertest": "^2.0.4",
"jest": "^21.2.1",
"nodemon": "^1.14.1", "nodemon": "^1.14.1",
"supertest": "^3.0.0",
"tslint": "5.3.2", "tslint": "5.3.2",
"ts-jest": "^21.2.4",
"ts-node": "^4.1.0", "ts-node": "^4.1.0",
"tsconfig-paths": "^3.1.1" "tsconfig-paths": "^3.1.1"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
} }
} }

25
src/modules/app.spec.ts Normal file
View File

@ -0,0 +1,25 @@
import express from 'express';
import request from 'supertest';
import { Test } from '@nestjs/testing';
import { ApplicationModule } from './app.module';
describe('Basic E2E Test', () => {
const server = express();
beforeAll(async () => {
const module = await Test.createTestingModule({
modules: [ApplicationModule]
})
.compile();
const app = module.createNestApplication(server);
await app.init();
});
it('/GET /', () => {
return request(server)
.get('/')
.expect(200)
.expect('Hello World!');
});
});

View File

@ -5,6 +5,7 @@
"noImplicitAny": false, "noImplicitAny": false,
"removeComments": true, "removeComments": true,
"noLib": false, "noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"target": "es6", "target": "es6",

3934
yarn.lock Normal file

File diff suppressed because it is too large Load Diff