Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are really trying to mock out the backend in a E2E test (these tests are called Scenarios, while Specs are used for unit testing) then this is what I did in a project I was working on earlier. </p> <p>The application I was testing was called <code>studentsApp</code>. It was an application to search for students by querying a REST api. I wanted to test the application without actually querying that api. </p> <p>I created a E2E application called <code>studentsAppDev</code> that I inject <code>studentsApp</code> and <code>ngMockE2E</code> into. There I define what calls the mockBackend should expect and what data to return. The following is an example of my <code>studentsAppDev</code> file:</p> <pre><code>"use strict"; // This application is to mock out the backend. var studentsAppDev = angular.module('studentsAppDev', ['studentsApp', 'ngMockE2E']); studentsAppDev.run(function ($httpBackend) { // Allow all calls not to the API to pass through normally $httpBackend.whenGET('students/index.html').passThrough(); var baseApiUrl = 'http://localhost:19357/api/v1/'; var axelStudent = { Education: [{...}], Person: {...} }; var femaleStudent = { Education: [{...}], Person: {...} }; $httpBackend.whenGET(baseApiUrl + 'students/?searchString=axe&amp;') .respond([axelStudent, femaleStudent]); $httpBackend.whenGET(baseApiUrl + 'students/?searchString=axel&amp;') .respond([axelStudent, femaleStudent]); $httpBackend.whenGET(baseApiUrl + 'students/?searchString=axe&amp;department=1&amp;') .respond([axelStudent]); $httpBackend.whenGET(baseApiUrl + 'students/?searchString=axe&amp;department=2&amp;') .respond([femaleStudent]); $httpBackend.whenGET(baseApiUrl + 'students/?searchString=axe&amp;department=3&amp;') .respond([]); ... $httpBackend.whenGET(baseApiUrl + 'departments/?teachingOnly=true') .respond([...]); $httpBackend.whenGET(baseApiUrl + 'majors?organization=RU').respond([...]); }); </code></pre> <p>Then, I have a first step in my Jenkins CI server to replace the <code>studentsApp</code> with <code>studentsAppDev</code> and add a reference to <code>angular-mocks.js</code> in the main index.html file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload