Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mrbrunelli/tdd-node-jest

My studies of test driven development (TDD) with Node.js
https://github.com/mrbrunelli/tdd-node-jest

jest node tdd

Last synced: about 1 month ago
JSON representation

My studies of test driven development (TDD) with Node.js

Awesome Lists containing this project

README

        

## :heavy_check_mark: TDD Node + Jest
> My studies of Test-driven development with Node.js

### Requisits
- [x] Node
- [x] Npm
- [x] Jest
- [x] Axios

### To execute
> First install the dependencies
```bash
npm install
```
> Later, execute npm test
```bash
npm test
```
> For coverage details
```bash
npx jest --coverage
```

![](./.github/terminal.png)

### Easy to test features
```javascript
const BranchController = require('./branch')

const makeSut = (url) => {
const sut = new BranchController(url)
return sut.handle(url)
}

describe('Branch Controller', () => {
test('Should return 200 if connect in /filial', async () => {
const statusCode = await makeSut('/api/filial')
expect(statusCode).toBe(200)
})

test('Should return 500 if provided incorrectly route', async () => {
const statusCode = await makeSut('invalid_route')
expect(statusCode).toBe(500)
})
})
```