Testing an integration #6825
-
Hi! I'm working on an integration for breadcrumb support for pino(#4192). I've made a temporary repository for some fast testing, I've made the import {Pino} from "../src/index";
import { EventHint, captureMessage, NodeClient } from "@sentry/node";
import pino from "pino";
import { createTransport, Hub } from '@sentry/core';
import { resolvedSyncPromise } from '@sentry/utils';
import { NodeClientOptions } from "@sentry/node/types/types";
import * as sentryCore from '@sentry/core';
const logger = pino();
export function getDefaultNodeClientOptions(options: Partial<NodeClientOptions> = {}): NodeClientOptions {
return {
integrations: [new Pino(logger)],
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})),
stackParser: () => [],
instrumenter: 'sentry',
...options,
};
}
describe('basic', () => {
it('foo', () => {
let output: null | "beforeSend" = null;
const options = getDefaultNodeClientOptions({
beforeSend: (event, hint: EventHint) => {
output = "beforeSend";
return null;
},
})
const client = new NodeClient(options);
const hub = new Hub(client);
sentryCore.makeMain(hub);
logger.info({data: {"someData": "yes!"}}, "Log message");
hub.captureException(new Error("Here is an error"));
expect(output).toBe("beforeSend");
});
}); However:
I just want to test this, but without setting up a sentry project and having lots of side effects when I run the tests. I couldn't really find anything on how I can set up an integration and test it? Are there any good practices? |
Beta Was this translation helpful? Give feedback.
Answered by
AbhiPrasad
Jan 18, 2023
Replies: 1 comment
-
Locking as it seems it was a dup of #6826 (and you figured it out there). |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
smeubank
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Locking as it seems it was a dup of #6826 (and you figured it out there).