mercredi 7 juin 2017

Protractor mock REST request

I'm runing the following spec file from protractor-http-mock and trying to figure a way to add it on another project but it seams that i've been missing something because it doesn't pass the test neither issues poped up on the console indicating some directions

spec: http://ift.tt/2sh4ubV

var mock = require('protractor-http-mock');

describe('REST Request Content', function () {

    beforeEach(function () {
        mock([{
            request: {
                path: '/actions',
                method: 'POST',
                regex: false, // Boolean to enable Regular Expression matching on path. This is an optional field.

                data: { // These match POST data. This is an optional field.
                    detail: 'CHAVE'
                }

            },
            response: {
                data: { // This is the return value for the matched request
                    actionName: 'LicensePlateEntered',
                    actionValue: '62LZS7',
                    message: 'Created. Action accepted for processing.'
                },
                status: 201 // The HTTP status code for the mocked response. This is an optional field.
            }
        }]);
    });

    afterEach(function(){
        mock.teardown();
    });

    it('should have REST POST request verified', function (){
        console.log("ENTROU");

        console.log("mock.requestsMade().actionName: " +mock.requestsMade().actionName);

        expect(mock.requestsMade()).toEqual([
            {
                url : '/actions', 
                method : 'POST',
                /*                 
                data : { 
                    actionName : 'LicensePlateEntered', 
                    actionValue: '62LZS7', 
                    message: 'Created. Action accepted for processing.'
                } 
                */
                data : { 
                    detail: 'CHAVE'
                } 

             }            
        ]);
    });
});

Aucun commentaire:

Enregistrer un commentaire