Skip to content

Commit a748e7e

Browse files
committed
Actualización jest para pasar todos los tests
1 parent 3574352 commit a748e7e

8 files changed

Lines changed: 1207 additions & 612 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
/.sass-cache
3636
/connect.lock
3737
/coverage
38+
/.jest-cache
3839
/libpeerconnection.log
3940
npm-debug.log
4041
yarn-error.log

jest.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ module.exports = {
2222
'jest-preset-angular/build/serializers/no-ng-attributes',
2323
'jest-preset-angular/build/serializers/ng-snapshot',
2424
'jest-preset-angular/build/serializers/html-comment'
25-
]
25+
],
26+
// Optimizaciones de performance
27+
maxWorkers: '50%',
28+
cache: true,
29+
cacheDirectory: '<rootDir>/.jest-cache',
30+
testTimeout: 10000
2631
};

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"@types/faker": "4.1.5",
123123
"@types/fs-extra": "2.1.0",
124124
"@types/glob": "5.0.33",
125-
"@types/jest": "29.5.10",
125+
"@types/jest": "^30.0.0",
126126
"@types/node": "^20.19.0",
127127
"@types/ora": "1.3.1",
128128
"@types/rimraf": "0.0.28",
@@ -148,10 +148,11 @@
148148
"fs-extra": "2.1.2",
149149
"gh-pages": "1.1.0",
150150
"glob": "7.1.2",
151-
"jest": "29.6.2",
152-
"jest-environment-jsdom": "29.6.2",
153-
"jest-preset-angular": "^14.0.0",
151+
"jest": "^30.0.0",
152+
"jest-environment-jsdom": "^30.0.0",
153+
"jest-preset-angular": "^15.0.0",
154154
"jest-zone-patch": "0.0.10",
155+
"jsdom": "^26.0.0",
155156
"lint-staged": "7.2.2",
156157
"module-alias": "2.0.0",
157158
"ncp": "2.0.0",
@@ -165,7 +166,7 @@
165166
"rollup": "0.50.0",
166167
"sorcery": "0.10.0",
167168
"to-fast-properties": "^2.0.0",
168-
"ts-jest": "29.1.1",
169+
"ts-jest": "^29.2.0",
169170
"ts-mockito": "2.3.1",
170171
"ts-node": "3.1.0",
171172
"typescript": "5.8.2",

projects/ngx-jsonapi-lib/src/lib/resource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ export class Resource implements ICacheable {
267267
public hasOneRelated(resource: string): boolean {
268268
return Boolean(
269269
this.relationships[resource] &&
270-
(<Resource>this.relationships[resource].data).type &&
271-
(<Resource>this.relationships[resource].data).type !== ''
270+
(<Resource>this.relationships[resource].data).type &&
271+
(<Resource>this.relationships[resource].data).type !== ''
272272
);
273273
}
274274

projects/ngx-jsonapi-lib/src/lib/sources/http.service.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { TestBed, waitForAsync } from '@angular/core/testing';
1+
import { TestBed } from '@angular/core/testing';
22
import { JsonapiConfig } from '../jsonapi-config';
3-
import { HttpClientTestingModule } from '@angular/common/http/testing';
3+
import { provideHttpClient } from '@angular/common/http';
4+
import { provideHttpClientTesting } from '@angular/common/http/testing';
45
import { tap, mapTo, share } from 'rxjs/operators';
56
import { Observable, of, timer, Subject } from 'rxjs';
67

@@ -20,14 +21,18 @@ describe('Http service', () => {
2021
},
2122
meta: { meta: 'meta' }
2223
};
23-
beforeEach(waitForAsync(() => {
24+
beforeEach(() => {
2425
TestBed.configureTestingModule({
25-
imports: [HttpClientTestingModule],
26-
providers: [Http, { provide: JsonapiConfig, useValue: JsonapiConfigMock }]
27-
}).compileComponents();
28-
}));
29-
it('should create Http service', () => {
26+
providers: [
27+
Http,
28+
{ provide: JsonapiConfig, useValue: JsonapiConfigMock },
29+
provideHttpClient(),
30+
provideHttpClientTesting()
31+
]
32+
});
3033
service = TestBed.inject(Http);
34+
});
35+
it('should create Http service', () => {
3136
expect(service).toBeTruthy();
3237
});
3338
it('exec should return an observable with the http request', async () => {

projects/ngx-jsonapi-lib/src/lib/sources/store.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// import 'localforage-getitems';
2-
import { TestBed, waitForAsync } from '@angular/core/testing';
2+
import { TestBed } from '@angular/core/testing';
33
import { StoreService } from './store.service';
44
// import * as localForage from 'localforage';
55
// import { extendPrototype as extendGetitems } from 'localforage-getitems';
@@ -11,12 +11,12 @@ import { IObjectsById } from '../interfaces';
1111

1212
describe('Store service', () => {
1313
let store_service: StoreService;
14-
beforeEach(waitForAsync(() => {
14+
beforeEach(() => {
1515
TestBed.configureTestingModule({
1616
providers: [StoreService]
17-
}).compileComponents();
17+
});
1818
store_service = TestBed.inject(StoreService);
19-
}));
19+
});
2020

2121
it('should create Store service', () => {
2222
expect(store_service).toBeTruthy();

setup-jest.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
declare var global: any;
22
declare const require: any;
3-
try {
4-
require('zone.js');
5-
} catch (e) {}
6-
try {
7-
require('zone.js/testing');
8-
} catch (e) {}
9-
import 'jest-preset-angular/setup-jest';
3+
4+
const { setupZoneTestEnv } = require('jest-preset-angular/setup-env/zone');
5+
6+
setupZoneTestEnv();
7+
108
import 'fake-indexeddb/auto';
11-
import { TestBed } from '@angular/core/testing';
12-
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
13-
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
149
global['CSS'] = null;
1510
Object.defineProperty(document.body.style, 'transform', {
1611
value: (): Object => {

0 commit comments

Comments
 (0)