Skip to content

Commit 226fb24

Browse files
committed
Cleanup jest config
1 parent 4a4ac68 commit 226fb24

7 files changed

+118
-881
lines changed

apps/ng2-charts-demo/jest.config.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
/* eslint-disable */
2-
import * as fin from 'chartjs-chart-financial';
32
// eslint-disable-next-line @typescript-eslint/no-var-requires
4-
// const fin = require('chartjs-chart-financial');
5-
console.log(fin);
63

74
const esModules = [
8-
'@angular',
9-
'lodash-es',
10-
'chart.js',
11-
'chartjs-chart-financial',
5+
'lodash-es'
126
].join('|');
137
export default {
148
displayName: 'ng2-charts',
@@ -33,4 +27,8 @@ export default {
3327
'jest-preset-angular/build/serializers/ng-snapshot',
3428
'jest-preset-angular/build/serializers/html-comment',
3529
],
30+
testMatch: [
31+
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
32+
'<rootDir>/src/**/*(*.)@(spec|test).[jt]s?(x)',
33+
],
3634
};

apps/ng2-charts-demo/src/app/app.component.ts

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
2828
public isDarkTheme = false;
2929

3030
public themeChanged() {
31-
console.log(this.isDarkTheme);
32-
3331
this.renderer.removeClass(this.document.body, darkThemeClass);
3432

3533
let overrides: ChartOptions;

apps/ng2-charts-demo/src/app/line-chart/line-chart.component.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
33
import { LineChartComponent } from './line-chart.component';
44
import { NgChartsModule } from 'ng2-charts';
55

6-
import 'chartjs-plugin-annotation';
7-
86
describe('LineChartComponent', () => {
97
let component: LineChartComponent;
108
let fixture: ComponentFixture<LineChartComponent>;

apps/ng2-charts-demo/src/app/line-chart/line-chart.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, ViewChild } from '@angular/core';
22
import { Chart, ChartConfiguration, ChartEvent, ChartType } from 'chart.js';
33
import { BaseChartDirective } from 'ng2-charts';
44

5-
import { default as Annotation } from 'chartjs-plugin-annotation';
5+
import Annotation from 'chartjs-plugin-annotation';
66

77
@Component({
88
selector: 'app-line-chart',
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { Chart } from 'chart.js';
2-
3-
// @ts-expect-error TS2339: Property 'Chart' does not exist on type 'Window & typeof globalThis'.
4-
window.Chart = Chart;
5-
61
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
72
globalThis.ngJest = {
83
testEnvironmentOptions: {
94
errorOnUnknownElements: true,
105
errorOnUnknownProperties: true,
116
},
127
};
8+
9+
global.ResizeObserver = jest.fn().mockImplementation(() => ({
10+
observe: jest.fn(),
11+
unobserve: jest.fn(),
12+
disconnect: jest.fn(),
13+
}))
14+
15+
16+
// @ts-expect-error TS2339: Property 'Chart' does not exist on type 'Window & typeof global'.
17+
global.Chart = {
18+
plugins: []
19+
};
20+
1321
import 'jest-preset-angular/setup-jest';
1422
import 'jest-canvas-mock';
15-
16-
window.ResizeObserver =
17-
window.ResizeObserver ||
18-
jest.fn().mockImplementation(() => ({
19-
disconnect: jest.fn(),
20-
observe: jest.fn(),
21-
unobserve: jest.fn(),
22-
}));

0 commit comments

Comments
 (0)