Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/hodfords-solutions/nestjs-testing

Provides some tools for implementing Unit test in Nestjs
https://github.com/hodfords-solutions/nestjs-testing

nestjs nodejs testing

Last synced: 1 day ago
JSON representation

Provides some tools for implementing Unit test in Nestjs

Awesome Lists containing this project

README

        


Nest Logo


Nestjs-Testing is a testing library for Nestjs applications. It provides a set of utilities to help you test your Nestjs application.

## Installation 🤖
To begin using it, we first install the required dependencies.
```
npm install @hodfords/nestjs-testing
```

## Configuration 🚀
To easily customize the configuration, let's create an object that extends the `BaseTestHelper` class. This object will be used to configure the test environment.

```typescript
export class TestHelper extends BaseTestHelper {
getSupertestConfig(): SupertestConfig {
return {
isUseBearerAuth: true,
authenticationHeader: 'Authorization'
};
}

getTestModuleBuilder(): TestingModuleBuilder {
return Test.createTestingModule({
imports: [AppModule]
});
}
}
```

## Usage 🚀

Write your test cases using the `TestHelper` class.

```typescript
describe('AppController (e2e)', () => {
let testHelper = new TestHelper();

beforeAll(async () => {
await testHelper.initialize();
});

it('Get index success', async () => {
return testHelper.get('/').isOk().expect('Hello World!');
});
});
```

## License
This project is licensed under the MIT License