Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CRoberto1926 committed Nov 19, 2024
1 parent af970cc commit dbb249c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions web/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');

const esModules = ['lodash-es'].join('|');

module.exports = {
preset: 'jest-preset-angular',
roots: ['<rootDir>/src'],
modulePaths: ['<rootDir>'],
moduleDirectories: ['node_modules', 'src'],
testMatch: ['**/+(*.)+(spec).+(ts)'],
setupFilesAfterEnv: ['<rootDir>/src/test.ts'],
transform: {
'^.+\\.mjs$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json'
}
]
},
transformIgnorePatterns: [`node_modules/(?!.*\\.mjs$|${esModules})`],
collectCoverage: true,
coverageReporters: ['text'],
coverageDirectory: 'coverage/kadai-web',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ describe('CanvasComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([SettingsState]), MatDialogModule],
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()],
declarations: [CanvasComponent]
providers: [CanvasComponent, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();

fixture = TestBed.createComponent(CanvasComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { provideHttpClientTesting } from '@angular/common/http/testing';
import { MatDividerModule } from '@angular/material/divider';
import { RequestInProgressService } from '../../../shared/services/request-in-progress/request-in-progress.service';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

@Pipe({ name: 'germanTimeFormat' })
class GermanTimeFormatPipe implements PipeTransform {
Expand Down Expand Up @@ -64,14 +65,15 @@ describe('TaskPriorityReportComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([SettingsState]), MatTableModule, MatDividerModule],
declarations: [TaskPriorityReportComponent, GermanTimeFormatPipe, CanvasStub, TaskPriorityReportFilterStub],
imports: [NgxsModule.forRoot([SettingsState]), MatTableModule, MatDividerModule, NoopAnimationsModule],
declarations: [GermanTimeFormatPipe, CanvasStub, TaskPriorityReportFilterStub],
providers: [
RequestInProgressService,
{ provide: MonitorService, useValue: monitorServiceSpy },
{ provide: NotificationService, useValue: notificationServiceSpy },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
provideHttpClientTesting(),
TaskPriorityReportComponent
]
}).compileComponents();

Expand Down
1 change: 0 additions & 1 deletion web/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import 'jest-preset-angular/setup-jest';
import { fakeAsync } from '@angular/core/testing';

Object.defineProperty(window, 'CSS', { value: null });
Object.defineProperty(window, 'getComputedStyle', {
Expand Down

0 comments on commit dbb249c

Please sign in to comment.