🧩 Built-in Plugins

Plugin Testing

Test your custom Gauzy plugins.

Unit Testing Plugins

import { Test, TestingModule } from "@nestjs/testing";
import { MyPluginService } from "./my-plugin.service";

describe("MyPluginService", () => {
  let service: MyPluginService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        MyPluginService,
        {
          provide: "MY_PLUGIN_CONFIG",
          useValue: {
            apiKey: "test-key",
            endpoint: "https://test.api.com",
            enabled: true,
          },
        },
      ],
    }).compile();

    service = module.get(MyPluginService);
  });

  it("should be defined", () => {
    expect(service).toBeDefined();
  });

  it("should process data", async () => {
    const result = await service.process({ input: "test" });
    expect(result).toBeDefined();
  });
});

Integration Testing

describe("MyPlugin Integration", () => {
  let app: INestApplication;

  beforeAll(async () => {
    const module = await Test.createTestingModule({
      imports: [AppModule, MyPluginModule],
    }).compile();

    app = module.createNestApplication();
    await app.init();
  });

  it("should register plugin endpoint", async () => {
    await request(app.getHttpServer()).get("/api/my-plugin/status").expect(200);
  });

  afterAll(async () => {
    await app.close();
  });
});

Mocking External Services

const mockExternalApi = {
  fetchData: jest.fn().mockResolvedValue({ success: true }),
  sendNotification: jest.fn().mockResolvedValue(true),
};

// In module
providers: [{ provide: ExternalApiService, useValue: mockExternalApi }];

Edit this page

Copyright © 2023-Present Ever Co. LTD.Docs by Sourcey