Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngMock - why does $httpBackend match the first and not the last mock definition? #11637

@szimek

Description

@szimek

Is there any reason why $httpBackend matches the first and not the last mock definition? If it worked the other way around (i.e. $httpBackend.when added new mock definitions to the beginning of definitions array instead of the end of it) it would be much easier to overwrite already mocked requests.

I've got some default mock definitions common for almost all tests that are loaded before each test and would like to be able to easily overwrite them in some specific tests.

I wanted to prepare PR that changes this, but there's even a unit test that explicitly checks for this behavior.

EDIT: In ngMock module unit tests like should match headers if specified or should match data if specified, the first mocks are more specific than the later ones. In a real app, I'd expect something opposite - one would create general mocks for most tests and then define more specific ones in selected tests.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions