Skip to content

Commit d89e244

Browse files
committed
test(node) add lineno and colno limits
1 parent a8c6a91 commit d89e244

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/node/test/integrations/contextlines.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from 'node:fs';
22
import type { StackFrame } from '@sentry/types';
33
import { parseStackFrames } from '@sentry/utils';
44

5-
import { _contextLinesIntegration, resetFileContentCache, MAX_CONTEXTLINES_COLNO } from '../../src/integrations/contextlines';
5+
import { _contextLinesIntegration, resetFileContentCache, MAX_CONTEXTLINES_COLNO, MAX_CONTEXTLINES_LINENO } from '../../src/integrations/contextlines';
66
import { defaultStackParser } from '../../src/sdk/api';
77
import { getError } from '../helpers/error';
88

@@ -23,7 +23,7 @@ describe('ContextLines', () => {
2323
});
2424

2525
describe('limits', () => {
26-
test('colno limit', async () => {
26+
test(`colno above ${MAX_CONTEXTLINES_COLNO}`, async () => {
2727
expect.assertions(1);
2828
const frames: StackFrame[] = [
2929
{
@@ -38,6 +38,22 @@ describe('ContextLines', () => {
3838
await addContext(frames);
3939
expect(readStreamSpy).not.toHaveBeenCalled();
4040
})
41+
42+
test(`lineno above ${MAX_CONTEXTLINES_LINENO}`, async () => {
43+
expect.assertions(1);
44+
const frames: StackFrame[] = [
45+
{
46+
colno: 1,
47+
filename: 'file:///var/task/index.js',
48+
lineno: MAX_CONTEXTLINES_LINENO + 1,
49+
function: 'fxn1',
50+
},
51+
];
52+
53+
const readStreamSpy = jest.spyOn(fs, 'createReadStream');
54+
await addContext(frames);
55+
expect(readStreamSpy).not.toHaveBeenCalled();
56+
})
4157
})
4258

4359
describe('lru file cache', () => {

0 commit comments

Comments
 (0)