From a4ee3495943fbe60cfe17cfcb2fcc0357afee6af Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 2 Dec 2024 18:06:42 +0100 Subject: [PATCH] add esm integration test --- .../suites/contextLines/instrument.mjs | 10 +++++ .../contextLines/scenario with space.mjs | 5 +++ .../suites/contextLines/test.ts | 39 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 dev-packages/node-integration-tests/suites/contextLines/instrument.mjs create mode 100644 dev-packages/node-integration-tests/suites/contextLines/scenario with space.mjs create mode 100644 dev-packages/node-integration-tests/suites/contextLines/test.ts diff --git a/dev-packages/node-integration-tests/suites/contextLines/instrument.mjs b/dev-packages/node-integration-tests/suites/contextLines/instrument.mjs new file mode 100644 index 000000000000..599f86c7a925 --- /dev/null +++ b/dev-packages/node-integration-tests/suites/contextLines/instrument.mjs @@ -0,0 +1,10 @@ +import * as Sentry from '@sentry/node'; +import { loggingTransport } from '@sentry-internal/node-integration-tests'; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + release: '1.0', + autoSessionTracking: false, + transport: loggingTransport, + debug: true, +}); diff --git a/dev-packages/node-integration-tests/suites/contextLines/scenario with space.mjs b/dev-packages/node-integration-tests/suites/contextLines/scenario with space.mjs new file mode 100644 index 000000000000..ce9b5ee327df --- /dev/null +++ b/dev-packages/node-integration-tests/suites/contextLines/scenario with space.mjs @@ -0,0 +1,5 @@ +import * as Sentry from '@sentry/node'; + +Sentry.captureException(new Error('Test Error')); + +// some more post context diff --git a/dev-packages/node-integration-tests/suites/contextLines/test.ts b/dev-packages/node-integration-tests/suites/contextLines/test.ts new file mode 100644 index 000000000000..b785430fd7ea --- /dev/null +++ b/dev-packages/node-integration-tests/suites/contextLines/test.ts @@ -0,0 +1,39 @@ +import { join } from 'path'; +import { createRunner } from '../../utils/runner'; + +describe('ContextLines integration', () => { + test('reads context lines from filenames with spaces', done => { + expect.assertions(1); + const instrumentPath = join(__dirname, 'instrument.mjs'); + + createRunner(__dirname, 'scenario with space.mjs') + .withFlags('--import', instrumentPath) + .expect({ + event: { + exception: { + values: [ + { + value: 'Test Error', + stacktrace: { + frames: expect.arrayContaining([ + { + filename: expect.stringMatching(/\/scenario with space.mjs$/), + context_line: "Sentry.captureException(new Error('Test Error'));", + pre_context: ["import * as Sentry from '@sentry/node';", ''], + post_context: ['', '// some more post context'], + colno: 25, + lineno: 3, + function: '?', + in_app: true, + module: 'scenario%20with%20space', + }, + ]), + }, + }, + ], + }, + }, + }) + .start(done); + }); +});