Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Sep 10, 2024
1 parent 68a6e4c commit 39409c5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-disable no-unused-vars */
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');

Sentry.init({
dsn: 'https://[email protected]/1337',
includeLocalVariables: true,
transport: loggingTransport,
});

class Some {
two(name) {
throw new Error('Enough!');
}
}

function one(name) {
const arr = [1, '2', null];
const obj = {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';
const something = undefined;
const somethingElse = null;

const ty = new Some();

ty.two(name);
}

setTimeout(() => {
try{
try {
one('some name');
} catch (e) {
const more = 'here';
throw e;
}
} catch (e) {
Sentry.captureException(e);
}
}, 1000);
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ conditionalTest({ min: 18 })('LocalVariables integration', () => {
});
});

conditionalTest({ min: 20 })('Node v20+', () => {
test('Should retain original local variables when error is re-thrown', done => {
createRunner(__dirname, 'local-variables-rethrow.js')
.expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT })
.start(done);
});
});

test('Includes local variables for caught exceptions when enabled', done => {
createRunner(__dirname, 'local-variables-caught.js').expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }).start(done);
});
Expand Down

0 comments on commit 39409c5

Please sign in to comment.