Skip to content

Commit fc0e1d5

Browse files
committed
Add test for long line truncation
1 parent 8e111ff commit fc0e1d5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
coverage/
22
test/instrumentation/node-*
33
test/manual/largeModule.js
4+
test/fixtures/*

test/fixtures/long-line.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/raven.utils.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,34 @@ describe('raven.utils', function () {
121121
}
122122
});
123123

124+
it('should trim long source line in surrounding source context', function (done) {
125+
var parseStack = raven.utils.parseStack;
126+
var callback = function (frames) {
127+
var frame = frames.pop();
128+
frame.in_app.should.be.true;
129+
130+
var lineBefore = frame.pre_context[frame.pre_context.length - 1].trim();
131+
lineBefore.should.not.startWith('{snip}');
132+
lineBefore.should.endWith('{snip}');
133+
134+
var lineOf = frame.context_line.trim();
135+
lineOf.should.startWith('{snip}');
136+
lineOf.should.endWith('{snip}');
137+
lineOf.length.should.equal(154); // 140 limit + 7 for `{snip} ` and ` {snip}`
138+
lineOf.should.containEql("throw new Error('boom');");
139+
140+
var lineAfter = frame.post_context[0].trim();
141+
lineAfter.should.not.startWith('{snip}');
142+
lineAfter.should.endWith('{snip}');
143+
done();
144+
};
145+
try {
146+
require('./fixtures/long-line')();
147+
} catch (e) {
148+
parseStack(e, callback);
149+
}
150+
});
151+
124152
it('should treat windows files as being in app: in_app should be true', function (done) {
125153
var parseStack = raven.utils.parseStack;
126154
var callback = function (frames) {

0 commit comments

Comments
 (0)