Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"sinon": "^7.3.2",
"size-limit": "^4.5.5",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"ts-node": "10.9.1",
"tslib": "^2.3.1",
"typedoc": "^0.18.0",
"typescript": "3.8.3"
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"devDependencies": {
"@types/glob": "8.0.0",
"@types/node": "^14.6.4",
"glob": "8.0.3",
"ts-node": "10.9.1",
"typescript": "3.8.3",
Expand Down
13 changes: 10 additions & 3 deletions packages/gatsby/test/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { init as reactInitRaw, SDK_VERSION } from '@sentry/react';
import { init, SDK_VERSION } from '@sentry/react';
import { Integrations } from '@sentry/tracing';
import { Integration } from '@sentry/types';

import { init as gatsbyInit } from '../src/sdk';
import { UserIntegrations } from '../src/utils/integrations';
import { GatsbyOptions } from '../src/utils/types';

const reactInit = reactInitRaw as jest.Mock;
jest.mock('@sentry/react');
jest.mock('@sentry/react', () => {
const actual = jest.requireActual('@sentry/react');
return {
...actual,
init: jest.fn().mockImplementation(actual.init),
};
});

const reactInit = init as jest.Mock;

describe('Initialize React SDK', () => {
afterEach(() => reactInit.mockReset());
Expand Down
20 changes: 12 additions & 8 deletions packages/svelte/test/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { addGlobalEventProcessor, init as browserInitRaw, SDK_VERSION } from '@sentry/browser';
import { addGlobalEventProcessor, init as browserInit, SDK_VERSION } from '@sentry/browser';
import { EventProcessor } from '@sentry/types';

import { detectAndReportSvelteKit, init as svelteInit, isSvelteKitApp } from '../src/sdk';

const browserInit = browserInitRaw as jest.Mock;
const addGlobalEventProcessorFunction = addGlobalEventProcessor as jest.Mock;
let passedEventProcessor: EventProcessor | undefined;
addGlobalEventProcessorFunction.mockImplementation(proc => {
passedEventProcessor = proc;
});

jest.mock('@sentry/browser');
jest.mock('@sentry/browser', () => {
const actual = jest.requireActual('@sentry/browser');
return {
...actual,
init: jest.fn().mockImplementation(actual.init),
addGlobalEventProcessor: jest.fn().mockImplementation(proc => {
passedEventProcessor = proc;
}),
};
});

describe('Initialize Svelte SDk', () => {
afterAll(() => {
Expand Down Expand Up @@ -48,7 +52,7 @@ describe('detectAndReportSvelteKit()', () => {
it('registers a global event processor', async () => {
detectAndReportSvelteKit();

expect(addGlobalEventProcessorFunction).toHaveBeenCalledTimes(1);
expect(addGlobalEventProcessor).toHaveBeenCalledTimes(1);
expect(passedEventProcessor?.id).toEqual('svelteKitProcessor');
});

Expand Down
Loading