Nightwatch: How to mock your backend while using Nightwatch.js ?

Created on 14 Feb 2014  路  3Comments  路  Source: nightwatchjs/nightwatch

Hi guys,

Currently developing a frontend application using AngularJS which connects to a backend server, I am using Nightwatch.js to check my frontend interfaces.

I would like my frontend to display fake data and think about using a mock backend. What mock server would you recommand ?

I started using nock which looks very promising, but I am facing some problem. Nock does not intercepts my HTTP requests to my backend. It might be due to selenium which proxy requests from my local machine.

Any thoughts about how to achieve this ?

Thanks,

Most helpful comment

@t00f how tool you indicate to use for mocking http requests with nightwatch?

All 3 comments

Nock looks very nice indeed and has an extended api but it it's not well suited for your app I believe. Nock will be useful only for mocking node.js based apps/services, because it intercepts the calls to http.request and overrides their behaviour.

What you need is something built for whatever http library you're using in your frontend code. If you're using angularjs' $http module you can use ngMock.$httpBackend.

I used ngMock $httpBackend and it works fine. Thanks for your useful help !

@t00f how tool you indicate to use for mocking http requests with nightwatch?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgleonardoopitz picture sgleonardoopitz  路  3Comments

manjero picture manjero  路  4Comments

dakebl picture dakebl  路  4Comments

jvlaar picture jvlaar  路  4Comments

Zechtitus picture Zechtitus  路  4Comments