How to write JavaScript Integration Tests?

1.4k views Asked by At

I must write Integration Tests for a RequireJS application. I have never done that before and I don't find any examples on the Internet. Why is there that few information about that subject? I read many descriptions what Integration Tests are but I am still not sure how to write them. I have no server or db code for my application, this means I can only test the collaboration of the different modules, right? I already tried to write some tests with Jasmine, e.g. when render() is called in Module1, Module2 is instanciated and Module2.render() is called, too. Module2.render() should add some html code. Thus I used jasmine-jquery.js to test whether the html code was added: expect($('#test1')).toExist();

Is this an Integration Test? Or would this rather be added to Unit Tests?

I am also not sure, if I can write Integration Tests with Nightwatch.js and if this would be reasonable. I am now writing System Tests with this Framework, but it seems to be a bit like integration testing, because I am testing, if the components work together. When is a Nightwatch test called Integration Test and when is it called System Test?

1

There are 1 answers

1
piotrek On

i would say that 'integration' test should check how does your js code 'integrate' with rest of the application. that is if it sends and receives correct messages to/from backend, if it communicates correctly with browser storage etc. What you describe looks like a unit test

i don't know nightwatch but according to their page

Nightwatch.js is an easy to use Node.js based End-to-End (E2E) testing solution for browser based apps and websites

it should get the job done