Add Integration and unit tests on Billing (#9317)
Solves [ https://github.com/twentyhq/private-issues/issues/214 ] **TLDR** Add unit and integration tests to Billing. First approach to run jest integration tests directly from VSCode. **In order to run the unit tests:** Run unit test using the CLI or with the jest extension directly from VSCode. **In order to run the integration tests:** Ensure that your database has the billingTables. If that's not the case, migrate the database with IS_BILLING_ENABLED set to true: ` npx nx run twenty-server:test:integration test/integration/billing/suites/billing-controller.integration-spec.ts` **Doing:** - Unit test on transformSubscriptionEventToSubscriptionItem - More tests cases in billingController integration tests. --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Weiko <corentin@twenty.com> Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4ed1db3845
commit
c39af5f063
@ -2,6 +2,8 @@ import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { Test, TestingModule, TestingModuleBuilder } from '@nestjs/testing';
|
||||
|
||||
import { AppModule } from 'src/app.module';
|
||||
import { StripeSDKMockService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/mocks/stripe-sdk-mock.service';
|
||||
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
|
||||
|
||||
interface TestingModuleCreatePreHook {
|
||||
(moduleBuilder: TestingModuleBuilder): TestingModuleBuilder;
|
||||
@ -23,9 +25,12 @@ export const createApp = async (
|
||||
appInitHook?: TestingAppCreatePreHook;
|
||||
} = {},
|
||||
): Promise<NestExpressApplication> => {
|
||||
const stripeSDKMockService = new StripeSDKMockService();
|
||||
let moduleBuilder: TestingModuleBuilder = Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
});
|
||||
})
|
||||
.overrideProvider(StripeSDKService)
|
||||
.useValue(stripeSDKMockService);
|
||||
|
||||
if (config.moduleBuilderHook) {
|
||||
moduleBuilder = config.moduleBuilderHook(moduleBuilder);
|
||||
@ -33,7 +38,10 @@ export const createApp = async (
|
||||
|
||||
const moduleFixture: TestingModule = await moduleBuilder.compile();
|
||||
|
||||
const app = moduleFixture.createNestApplication<NestExpressApplication>();
|
||||
const app = moduleFixture.createNestApplication<NestExpressApplication>({
|
||||
rawBody: true,
|
||||
cors: true,
|
||||
});
|
||||
|
||||
if (config.appInitHook) {
|
||||
await config.appInitHook(app);
|
||||
|
||||
Reference in New Issue
Block a user