-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yorty Ruiz Hernandez
committed
Jan 22, 2024
1 parent
7efc791
commit f7194d5
Showing
2 changed files
with
99 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# BuildNumbr.com Development Guide | ||
## Installation | ||
|
||
```bash | ||
$ npm install | ||
``` | ||
|
||
## Running the app | ||
|
||
```bash | ||
# development | ||
$ npm run start | ||
|
||
# watch mode | ||
$ npm run start:dev | ||
|
||
# production mode | ||
$ npm run start:prod | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ npm run test | ||
|
||
# e2e tests | ||
$ npm run test:e2e | ||
|
||
# test coverage | ||
$ npm run test:cov | ||
``` | ||
|
||
## Code Formatting | ||
|
||
```bash | ||
# prettier | ||
$ npm run format | ||
|
||
# eslint | ||
$ npm run lint | ||
``` | ||
|
||
## Logging | ||
|
||
```ts | ||
import { Logger, Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
class MyService { | ||
private readonly logger = new Logger(MyService.name); | ||
|
||
doSomething() { | ||
this.logger.log('Doing something...'); | ||
} | ||
} | ||
``` | ||
|
||
## Testing | ||
|
||
```ts | ||
import { Test } from '@nestjs/testing'; | ||
import { CatsController } from './cats.controller'; | ||
import { CatsService } from './cats.service'; | ||
import { jest } from '@jest/globals'; | ||
|
||
describe('CatsController', () => { | ||
let catsController: CatsController; | ||
const catsServiceMock = { | ||
findAll: jest.fn(), | ||
}; | ||
|
||
beforeEach(async () => { | ||
const moduleRef = await Test.createTestingModule({ | ||
controllers: [CatsController], | ||
providers: [{ | ||
provides: CatsService, | ||
useValue: catsServiceMock, | ||
}], | ||
}).compile(); | ||
|
||
catsController = moduleRef.get<CatsController>(CatsController); | ||
}); | ||
|
||
describe('findAll', () => { | ||
it('should return an array of cats', async () => { | ||
// Arrange | ||
const result = ['test']; | ||
catsServiceMock.findAll.mockImplementation(() => result); | ||
|
||
// Act | ||
const actual = await catsController.findAll(); | ||
|
||
// Assert | ||
expect(actual).toBe(result); | ||
}); | ||
}); | ||
}); | ||
``` |
This file was deleted.
Oops, something went wrong.