Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/hodfords-solutions/nestjs-testing
- Owner: hodfords-solutions
- Created: 2024-09-23T03:39:34.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-09T10:19:03.000Z (3 months ago)
- Last Synced: 2025-01-01T13:06:11.148Z (8 days ago)
- Topics: nestjs, nodejs, testing
- Language: TypeScript
- Homepage: https://opensource.hodfords.uk/nestjs-testing
- Size: 197 KB
- Stars: 42
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
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