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.$httpBackend: statement defined in beforeEach block should be possible to have response redefined in it() block #5766

Closed
@jrencz

Description

@jrencz

I was trying to write a test of error branch of $http request.
I found it's not possible to redefine response for certain url after it's defined in beforeEach() block, which I find wrong.

Take a look at http://plnkr.co/edit/ygWP6nIV7L5PjkHrtmbG

It should be possible to define 2xx response in beforeEach() and then change its response code in one test if it's needed.

This problem doesn't seem to be new: I found half year old Stack Overflow thread describing how to solve the problem but declaring $httpBackend.when() on each it() block: http://stackoverflow.com/questions/17858955/how-to-override-mocked-response-of-httpbackend-in-angular but i'm convinced this is not the best, or most elegant way to do.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions