forked from getsentry/sentry-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
139 lines (115 loc) · 3.97 KB
/
test.ts
File metadata and controls
139 lines (115 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { expect } from '@playwright/test';
import fs from 'fs';
import path from 'path';
import { sentryTest } from '../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequest } from '../../../utils/helpers';
import { shouldSkipWASMTests } from '../../../utils/wasmHelpers';
declare global {
interface Window {
wasmWorker: Worker;
triggerWasmError: () => void;
}
}
const bundle = process.env.PW_BUNDLE || '';
if (bundle.startsWith('bundle')) {
sentryTest.skip();
}
sentryTest(
'WASM debug images from worker should be forwarded to main thread and attached to events',
async ({ getLocalTestUrl, page, browserName }) => {
if (shouldSkipWASMTests(browserName)) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
await page.route('**/simple.wasm', route => {
const wasmModule = fs.readFileSync(path.resolve(__dirname, '../simple.wasm'));
return route.fulfill({
status: 200,
body: wasmModule,
headers: {
'Content-Type': 'application/wasm',
},
});
});
await page.route('**/worker.js', route => {
return route.fulfill({
path: `${__dirname}/assets/worker.js`,
});
});
const errorEventPromise = waitForErrorRequest(page, e => {
return e.exception?.values?.[0]?.value === 'WASM error from worker';
});
await page.goto(url);
await page.waitForFunction(() => window.wasmWorker !== undefined);
await page.evaluate(() => {
window.triggerWasmError();
});
const errorEvent = envelopeRequestParser(await errorEventPromise);
expect(errorEvent.exception?.values?.[0]?.value).toBe('WASM error from worker');
expect(errorEvent.debug_meta?.images).toBeDefined();
expect(errorEvent.debug_meta?.images).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'wasm',
code_file: expect.stringMatching(/simple\.wasm$/),
code_id: '0ba020cdd2444f7eafdd25999a8e9010',
debug_id: '0ba020cdd2444f7eafdd25999a8e90100',
}),
]),
);
expect(errorEvent.exception?.values?.[0]?.stacktrace?.frames).toEqual(
expect.arrayContaining([
expect.objectContaining({
filename: expect.stringMatching(/simple\.wasm$/),
platform: 'native',
instruction_addr: expect.stringMatching(/^0x[a-fA-F\d]+$/),
addr_mode: expect.stringMatching(/^rel:\d+$/),
}),
]),
);
},
);
sentryTest(
'WASM frames from worker should be recognized as first-party when applicationKey is configured',
async ({ getLocalTestUrl, page, browserName }) => {
if (shouldSkipWASMTests(browserName)) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
await page.route('**/simple.wasm', route => {
const wasmModule = fs.readFileSync(path.resolve(__dirname, '../simple.wasm'));
return route.fulfill({
status: 200,
body: wasmModule,
headers: {
'Content-Type': 'application/wasm',
},
});
});
await page.route('**/worker.js', route => {
return route.fulfill({
path: `${__dirname}/assets/worker.js`,
});
});
const errorEventPromise = waitForErrorRequest(page, e => {
return e.exception?.values?.[0]?.value === 'WASM error from worker';
});
await page.goto(url);
await page.waitForFunction(() => window.wasmWorker !== undefined);
await page.evaluate(() => {
window.triggerWasmError();
});
const errorEvent = envelopeRequestParser(await errorEventPromise);
expect(errorEvent.exception?.values?.[0]?.stacktrace?.frames).toEqual(
expect.arrayContaining([
expect.objectContaining({
filename: expect.stringMatching(/simple\.wasm$/),
platform: 'native',
module_metadata: expect.objectContaining({
'_sentryBundlerPluginAppKey:wasm-worker-app': true,
}),
}),
]),
);
},
);