Skip to content

Commit d930b3b

Browse files
committed
add test (plus jest config)
1 parent 9c1efcd commit d930b3b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

packages/angular/jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const baseConfig = require('../../jest/jest.config.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
testEnvironment: 'jsdom',
6+
};

packages/angular/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5353
"lint": "run-s lint:prettier lint:eslint",
5454
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
55-
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\""
55+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
56+
"test": "run-s test:unit",
57+
"test:unit": "jest",
58+
"test:unit:watch": "jest --watch"
5659
},
5760
"volta": {
5861
"extends": "../../package.json"

packages/angular/test/sdk.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as SentryBrowser from '@sentry/browser';
2+
3+
import { init } from '../src/sdk';
4+
5+
describe('init', () => {
6+
it('sets the Angular version (if available) in the global scope', () => {
7+
const setContextSpy = jest.spyOn(SentryBrowser, 'setContext');
8+
9+
init({});
10+
11+
// In our case, the Angular version is 10 because that's the version we use for compilation
12+
// (and hence the dependency version of Angular core we installed (see package.json))
13+
expect(setContextSpy).toHaveBeenCalledTimes(1);
14+
expect(setContextSpy).toHaveBeenCalledWith('angular', { version: 10 });
15+
});
16+
});

0 commit comments

Comments
 (0)