mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-31 00:04:05 -05:00
Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
30 lines
748 B
TypeScript
30 lines
748 B
TypeScript
import Fastify, { type FastifyInstance } from 'fastify';
|
|
import growthBook from './growth-book';
|
|
|
|
const captureException = jest.fn();
|
|
|
|
describe('growth-book', () => {
|
|
let fastify: FastifyInstance;
|
|
beforeAll(() => {
|
|
fastify = Fastify();
|
|
// @ts-expect-error we're mocking the Sentry plugin
|
|
fastify.Sentry = { captureException };
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await fastify.close();
|
|
});
|
|
|
|
it('should log the error if the GrowthBook initialization fails', async () => {
|
|
const spy = jest.spyOn(fastify.log, 'error');
|
|
|
|
await fastify.register(growthBook, {
|
|
apiHost: 'invalid-url',
|
|
clientKey: 'invalid-key'
|
|
});
|
|
|
|
expect(spy).toHaveBeenCalled();
|
|
expect(captureException).toHaveBeenCalled();
|
|
});
|
|
});
|