Skip to content

Commit e3ebab0

Browse files
committed
[Issue #6] Stack traces should be filtered by .ts extension
1 parent 0958cb5 commit e3ebab0

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [1.0.2]
44

55
### Fixes
6+
- [Issue #6] Stack traces should be filtered by .ts extension
67
- Typescript Template v2
78

89
## [1.0.1]

jasmine.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"spec_files": [ "**/*[sS]pec.js" ],
44
"helpers": [ "helpers/**/*.js" ],
55
"stopSpecOnExpectationFailure": false,
6-
"random": true
6+
"random": false
77
}

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export interface ErrorHandlerOptions {
2626
// Ignore node internals? (justMyCode must be true)
2727
justMyCodeIncludeInternals: boolean,
2828

29+
// Ignore javascript & compiled files?
30+
includeJsFiles: boolean,
31+
2932
// Error handler
3033
handler?: HandlerFunction,
3134
}
@@ -38,6 +41,7 @@ export const defaultOptions: ErrorHandlerOptions = {
3841
justMyCode: true,
3942
justMyCodeIncludeNodeModules: false,
4043
justMyCodeIncludeInternals: false,
44+
includeJsFiles: false,
4145

4246
// eslint-disable-next-line no-console
4347
handler: console.error
@@ -72,6 +76,10 @@ export function setupErrorHandling(options: Partial<ErrorHandlerOptions>) {
7276
.filter(line => {
7377
return (
7478
line &&
79+
(
80+
options.includeJsFiles ||
81+
!line.includes('.js')
82+
) &&
7583
(
7684
options.justMyCodeIncludeNodeModules ||
7785
!line.includes('node_modules')

test/spec/index.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { getStackTrace } from '../util/get-stack-trace';
66
describe('index', () => {
77
it('sets stack trace to "Just My Code"', () => {
88
setupErrorHandling({
9-
justMyCode: true
9+
justMyCode: true,
10+
includeJsFiles: true,
1011
});
1112

1213
const trace = getStackTrace();
@@ -15,4 +16,14 @@ describe('index', () => {
1516
expect(trace).not.toContain('node_modules');
1617
expect(trace).not.toContain('internal/');
1718
});
19+
20+
it('allows filtering of .js extension', () => {
21+
setupErrorHandling({
22+
justMyCode: true
23+
});
24+
25+
const trace = getStackTrace();
26+
27+
expect(trace).not.toContain('.js');
28+
});
1829
});

0 commit comments

Comments
 (0)