@hodfords/nestjs-testing
v0.0.2
Published
Provides some tools for implementing Unit test in Nestjs.
Downloads
1,305
Readme
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.
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.
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