Skip to content

Commit a473e0f

Browse files
committed
test(profiling) throw after each possible culprit
1 parent 7b07ab9 commit a473e0f

File tree

1 file changed

+15
-6
lines changed
  • dev-packages/e2e-tests/test-applications/node-profiling

1 file changed

+15
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
function assertUnpatechedRequire(cycle) {
2+
if (globalThis.require !== undefined) {
3+
// Test that globalThis.require is not defined by any side effects of the profiling
4+
// https://github.com/getsentry/sentry-javascript/issues/13662
5+
throw new Error(
6+
`globalThis.require should not be defined ${cycle}, check that profiling integration is not defining it, received: ` +
7+
typeof globalThis.require,
8+
);
9+
}
10+
}
11+
12+
assertUnpatechedRequire('at startup');
113
import * as Sentry from '@sentry/node';
14+
assertUnpatechedRequire('after importing sentry/node');
215
import { nodeProfilingIntegration } from '@sentry/profiling-node';
3-
16+
assertUnpatechedRequire('after importing sentry/profiling-node');
417
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
518

619
Sentry.init({
@@ -14,8 +27,4 @@ Sentry.startSpan({ name: 'Precompile test' }, async () => {
1427
await wait(500);
1528
});
1629

17-
// Test that globalThis.require is not defined by any side effects of the profiling
18-
// https://github.com/getsentry/sentry-javascript/issues/13662
19-
if (globalThis.require !== undefined) {
20-
throw new Error('globalThis.require should not be defined, check that profiling integration is not defining it, received: ' + typeof globalThis.require);
21-
}
30+
assertUnpatechedRequire('after a span was created');

0 commit comments

Comments
 (0)