1

Creating my first mock api is turning out to be very unsuccessful.

I followed two solutions:

AngularJS & Jasmine HTTP Backend

Mock HTTP Backend e2e Tests

And my implementation:

describe('[user story] The user would like to capture contractor drilling information', function() {

    beforeEach(module('contractor_drilling'));

    var $httpBackend;

    beforeEach(inject(function($injector) {
        $httpBackend = $injector.get ('$httpBackend');

        $httpBackend
            .when ('GET', '/api/Block/Getblock/1')
            .respond ({
                id: 1 ,
                block_number: '11/11/11'
            });
    }));

    afterEach (function () {
        $httpBackend.verifyNoOutstandingExpectation ();
        $httpBackend.verifyNoOutstandingRequest ();
    });

    it ('should returns block data', function () {
        $httpBackend.expectGET ('/api/Block/Getblock/1');
        $httpBackend.flush ();
    });

Can anyone please give me an example on how to achieve this mock-API in an Cleverstack context.

The errors i'm getting:

TypeError: object is not a function @ beforeEach(module('contractor_drilling'));

ReferenceError: inject is not defined @ beforeEach(inject(function($injector) {

Now I read that you need to include angular-mock.js for my ReferenceError to be solved, but isn't cleverstack including this file somewhere already? or is it a setting to turn on or off in cleverstack.

I'm new to cleverstack and quite new to AngularJS so a good thorough explanation would be very helpfull.

Thanks.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.