test(sample/01) fix broken tests

- update jest configuration to remove warnings
- fix tests so that they run out of the box with correct types
- remove duplicate key from docker-compose
This commit is contained in:
Jesse Carter
2019-03-26 11:29:26 -04:00
parent 15bbd74cf8
commit 2eb2a037b8
5 changed files with 5456 additions and 5 deletions

View File

@@ -24,7 +24,6 @@ services:
restart: always
mysql:
image: mysql:5.7.25
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
@@ -43,4 +42,4 @@ services:
ports:
- "15672:15672"
- "5672:5672"
tty: true
tty: true

View File

@@ -6,7 +6,7 @@
"json"
],
"transform": {
"^.+\\.tsx?$": "<rootDir>/../node_modules/ts-jest/preprocessor.js"
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/e2e/.*\\.(e2e-test|e2e-spec).(ts|tsx|js)$",
"collectCoverageFrom" : ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],

View File

@@ -6,7 +6,7 @@
"json"
],
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/src/.*\\.(test|spec).(ts|tsx|js)$",
"collectCoverageFrom" : ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],

5445
sample/01-cats-app/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
import { Test } from '@nestjs/testing';
import { CatsController } from './cats.controller';
import { CatsService } from './cats.service';
import { Cat } from './interfaces/cat.interface';
describe('CatsController', () => {
let catsController: CatsController;
@@ -18,7 +19,13 @@ describe('CatsController', () => {
describe('findAll', () => {
it('should return an array of cats', async () => {
const result = ['test'];
const result: Cat[] = [
{
age: 2,
breed: 'Bombay',
name: 'Pixel',
},
];
jest.spyOn(catsService, 'findAll').mockImplementation(() => result);
expect(await catsController.findAll()).toBe(result);