mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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/**"],
|
||||
|
||||
@@ -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
5445
sample/01-cats-app/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user