Skip to content

Commit 21f5be4

Browse files
author
Luismi Ramírez
authored
Merge pull request #517 from appsignal/add-packages-missing-tests
Add tests for Angular package
2 parents 2db0d52 + f617116 commit 21f5be4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

packages/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build:watch": "run-p build:cjs:watch build:esm:watch",
1616
"clean": "rimraf dist coverage",
1717
"link:yarn": "yarn link",
18-
"test": "jest --passWithNoTests",
18+
"test": "jest",
1919
"test:watch": "jest --watch"
2020
},
2121
"dependencies": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { AppsignalErrorHandler } from "../index"
2+
3+
describe("Angular handleError", () => {
4+
let appsignal: any
5+
6+
const mock: any = {
7+
setError: jest.fn(() => mock),
8+
setTags: jest.fn(() => mock)
9+
}
10+
11+
const SpanMock = jest.fn().mockImplementation(() => mock)
12+
13+
beforeEach(() => {
14+
appsignal = {
15+
createSpan: () => new SpanMock(),
16+
send: jest.fn()
17+
}
18+
})
19+
20+
it("calls AppSignal helper methods", () => {
21+
const err = new Error("test")
22+
const errorHandler = new AppsignalErrorHandler(appsignal)
23+
24+
errorHandler.handleError(err)
25+
26+
expect(mock.setError).toBeCalledWith(err)
27+
expect(mock.setTags).toBeCalledWith({
28+
framework: "Angular"
29+
})
30+
31+
expect(appsignal.send).toBeCalledWith(mock)
32+
})
33+
})

0 commit comments

Comments
 (0)