Skip to content

Commit bbf63eb

Browse files
authored
fix: custom matchers are not available when using createHttpFactory (#736)
1 parent d7daf1c commit bbf63eb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

projects/spectator/src/lib/spectator-http/create-factory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Provider, Type } from '@angular/core';
44
import { TestBed } from '@angular/core/testing';
55

66
import { BaseSpectatorOverrides } from '../base/options';
7+
import { addMatchers } from '../core';
8+
import * as customMatchers from '../matchers';
79
import { isType } from '../types';
810

911
import { initialHttpModule } from './initial-module';
@@ -30,6 +32,7 @@ export function createHttpFactory<S>(typeOrOptions: Type<S> | SpectatorHttpOptio
3032
const moduleMetadata = initialHttpModule(options);
3133

3234
beforeEach(() => {
35+
addMatchers(customMatchers);
3336
TestBed.configureTestingModule(moduleMetadata);
3437
overrideModules(options);
3538
});

projects/spectator/test/todos-data.service.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,16 @@ describe('HttpClient testing', () => {
5757

5858
spectatorHttp.expectOne('two', HttpMethod.GET);
5959
}));
60+
61+
it('should work wih custom matchers', () => {
62+
const spectatorHttp = http();
63+
64+
spectatorHttp.service.get().subscribe((res) => {
65+
expect(res).toHaveProperty('id');
66+
expect(res).toHaveProperty('id', '1234');
67+
});
68+
69+
const req = spectatorHttp.expectOne('url', HttpMethod.GET);
70+
req.flush({ id: '1234' });
71+
});
6072
});

0 commit comments

Comments
 (0)