Skip to content

Commit 905a3a1

Browse files
author
Luca Forstner
authored
test(deno): Refer to local files in tests (#9297)
1 parent 753f82b commit 905a3a1

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

packages/deno/test/__snapshots__/mod.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ snapshot[`captureException 1`] = `
8282
filename: "app:///test/mod.test.ts",
8383
function: "<anonymous>",
8484
in_app: true,
85-
lineno: 43,
85+
lineno: 42,
8686
post_context: [
8787
"",
8888
" await delay(200);",
@@ -108,7 +108,7 @@ snapshot[`captureException 1`] = `
108108
filename: "app:///test/mod.test.ts",
109109
function: "something",
110110
in_app: true,
111-
lineno: 40,
111+
lineno: 39,
112112
post_context: [
113113
" }",
114114
"",

packages/deno/test/mod.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { assertEquals } from 'https://deno.land/[email protected]/assert/assert_equals.ts';
22
import { assertSnapshot } from 'https://deno.land/[email protected]/testing/snapshot.ts';
3-
import type { Event, Integration } from 'npm:@sentry/types';
4-
import { createStackParser, nodeStackLineParser } from 'npm:@sentry/utils';
53

4+
import { createStackParser, nodeStackLineParser } from '../../utils/build/esm/index.js';
65
import { defaultIntegrations, DenoClient, Hub, Scope } from '../build/index.js';
76
import { getNormalizedEvent } from './normalize.ts';
87
import { makeTestTransport } from './transport.ts';
98

10-
function getTestClient(callback: (event?: Event) => void, integrations: Integration[] = []): [Hub, DenoClient] {
9+
function getTestClient(callback: (event?: Event) => void, integrations: any[] = []): [Hub, DenoClient] {
1110
const client = new DenoClient({
1211
dsn: 'https://[email protected]/5650507',
1312
debug: true,
1413
integrations: [...defaultIntegrations, ...integrations],
1514
stackParser: createStackParser(nodeStackLineParser()),
1615
transport: makeTestTransport(envelope => {
1716
callback(getNormalizedEvent(envelope));
18-
}),
17+
}) as any,
1918
});
2019

2120
const scope = new Scope();

packages/deno/test/normalize.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
/* eslint-disable complexity */
2-
import type { Envelope, Event, Session, Transaction } from 'npm:@sentry/types';
3-
import { forEachEnvelopeItem } from 'npm:@sentry/utils';
2+
import { forEachEnvelopeItem } from '../../utils/build/esm/index.js';
43

5-
type EventOrSession = Event | Transaction | Session;
4+
type EventOrSession = any;
65

7-
export function getNormalizedEvent(envelope: Envelope): Event | undefined {
8-
let event: Event | undefined;
6+
export function getNormalizedEvent(envelope: any): any | undefined {
7+
let event: any | undefined;
98

10-
forEachEnvelopeItem(envelope, item => {
9+
forEachEnvelopeItem(envelope, (item: any) => {
1110
const [headers, body] = item;
1211

1312
if (headers.type === 'event') {
14-
event = body as Event;
13+
event = body;
1514
}
1615
});
1716

18-
return normalize(event) as Event | undefined;
17+
return normalize(event) as any | undefined;
1918
}
2019

2120
export function normalize(event: EventOrSession | undefined): EventOrSession | undefined {
@@ -24,14 +23,14 @@ export function normalize(event: EventOrSession | undefined): EventOrSession | u
2423
}
2524

2625
if (eventIsSession(event)) {
27-
return normalizeSession(event as Session);
26+
return normalizeSession(event);
2827
} else {
29-
return normalizeEvent(event as Event);
28+
return normalizeEvent(event);
3029
}
3130
}
3231

3332
export function eventIsSession(data: EventOrSession): boolean {
34-
return !!(data as Session)?.sid;
33+
return !!data?.sid;
3534
}
3635

3736
/**
@@ -40,7 +39,7 @@ export function eventIsSession(data: EventOrSession): boolean {
4039
* All properties that are timestamps, versions, ids or variables that may vary
4140
* by platform are replaced with placeholder strings
4241
*/
43-
function normalizeSession(session: Session): Session {
42+
function normalizeSession(session: any): any {
4443
if (session.sid) {
4544
session.sid = '{{id}}';
4645
}
@@ -66,7 +65,7 @@ function normalizeSession(session: Session): Session {
6665
* All properties that are timestamps, versions, ids or variables that may vary
6766
* by platform are replaced with placeholder strings
6867
*/
69-
function normalizeEvent(event: Event): Event {
68+
function normalizeEvent(event: any): any {
7069
if (event.sdk?.version) {
7170
event.sdk.version = '{{version}}';
7271
}
@@ -157,7 +156,7 @@ function normalizeEvent(event: Event): Event {
157156
if (event.exception?.values?.[0].stacktrace?.frames) {
158157
// Exlcude Deno frames since these may change between versions
159158
event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames.filter(
160-
frame => !frame.filename?.includes('deno:'),
159+
(frame: any) => !frame.filename?.includes('deno:'),
161160
);
162161
}
163162

0 commit comments

Comments
 (0)