@hodfords/nestjs-testing
v11.0.5
Published
Provides some tools for implementing Unit test in Nestjs.
Readme
Installation 🤖
To begin using it, we first install the required dependencies.
npm install @hodfords/nestjs-testingConfiguration 🚀
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',
workspaceHeader: 'x-workspace-id'
};
}
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
