-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.test.ts
More file actions
52 lines (44 loc) · 1.86 KB
/
index.test.ts
File metadata and controls
52 lines (44 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
import { uploadSourcemaps } from '@dd/error-tracking-plugin/sourcemaps/index';
import { getPlugins } from '@dd/error-tracking-plugin';
import { getContextMock, getSourcemapsConfiguration } from '@dd/tests/_jest/helpers/mocks';
import { BUNDLERS, runBundlers } from '@dd/tests/_jest/helpers/runBundlers';
jest.mock('@dd/error-tracking-plugin/sourcemaps/index', () => {
return {
uploadSourcemaps: jest.fn(),
};
});
const uploadSourcemapsMock = jest.mocked(uploadSourcemaps);
describe('Error Tracking Plugin', () => {
describe('getPlugins', () => {
test('Should not initialize the plugin if disabled', async () => {
expect(
getPlugins({ errorTracking: { disabled: true } }, getContextMock()),
).toHaveLength(0);
expect(getPlugins({}, getContextMock())).toHaveLength(0);
});
test('Should initialize the plugin if enabled', async () => {
expect(
getPlugins({ errorTracking: { disabled: false } }, getContextMock()).length,
).toBeGreaterThan(0);
});
});
test('Should process the sourcemaps if enabled.', async () => {
await runBundlers({
disableGit: true,
errorTracking: {
sourcemaps: getSourcemapsConfiguration(),
},
});
expect(uploadSourcemapsMock).toHaveBeenCalledTimes(BUNDLERS.length);
});
test('Should not process the sourcemaps with no options.', async () => {
await runBundlers({
disableGit: true,
errorTracking: {},
});
expect(uploadSourcemapsMock).not.toHaveBeenCalled();
});
});