Protractor tests are successful when run locally, but encounter failures when executed on Travis-CI

I recently integrated end-to-end tests using Protractor into my AngularJS application. Testing them locally showed that they all pass, but upon committing to GitHub and Travis for CI, most of the tests fail.

The failing tests seem to be those requiring navigation to different states (utilizing Angular UI Router).

scenarios.js

describe('Test', function () {

    beforeEach(function () {
        browser.get('/');
    })

    it('should navigate to the user page', function () {

        //browser.get("/");
        browser.sleep(3000);
        var button = element(by.id('createSession'));
        button.click().then(function () {
            browser.sleep(3000);
            expect(browser.getLocationAbsUrl()).toEqual("/user");
        });
    });

    // Further test cases go here...

});

protractor.conf.js

    exports.config = {

      allScriptsTimeout: 11000,

      specs: [
        "scenarios.js"
      ],

      capabilities: {
        "browserName": "chrome"
      },

      baseUrl: "http://localhost:8000/",

      framework: "jasmine",

      jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
      }

    };

package.json

    {
       // Package details go here...
}

.travis.yml

language: node_js
node_js:
  - '4.4'

addons:
  firefox: "latest"

// Configuration details go here...

It appears that the issue arises due to how the routing is handled with angular-seed's template. Any insights on why this discrepancy in test results is occurring?

Answer №1

It would be beneficial to understand the specific errors you are encountering, but regardless, there are a couple of evident causes...

  1. One possibility is that CI is operating in headless mode (via XVFB), while your local environment is not. This discrepancy can lead to timing issues.
  2. Excessive use of sleep commands may result in varying behavior of your tests across different environments (e.g., CI versus local). The presence of multiple sleep statements suggests possible flaws in test design. Additionally, if your application is not Angular, it is advisable to manage waits manually instead of relying on sleeps. However, if your application is Angular, the frequent use of sleeps raises questions about their necessity.

I hope this information provides some clarity for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A pair of demands within an express service

Currently, I'm facing an issue in a project where I am attempting to create a service using Express that makes two external API calls. However, I am encountering an error in Express that is difficult to comprehend. It seems like my approach might be i ...

Having trouble enabling push notifications on Android with ngCordova

Having trouble with push notifications through the ngCordova plugin. Followed the sample code from (with a slight change - no deviceready listener, code inside ionicPlatform.ready listener) Below is the code snippet: angular.module('myApp', [& ...

Is there a way to upload a kml file to Google Maps using my website or by using JavaScript commands?

I have information on my website regarding gas stations, including the quality of gasoline and the GPS coordinates of each station. My concept involves incorporating Google Maps into my site, similar to how flightradar24.com displays pins indicating gas s ...

Setting up a React application and API on the same port: A step-by-step guide

I have developed a React app that fetches data from a separate database through an API. While testing the app locally, it runs on one port while the API runs on another port. Since I need to make AJAX calls from the app to the API, I have to specify the ...

The combination of Array.pop and Array.indexOf is not functioning as expected

I'm having an issue with using Array.pop(Array.indexOf(value)). It seems to always delete the last element in the index, even if the value of that index is not what I intended. Can someone provide some guidance on how to resolve this? CheckBoxHandle ...

Different choices for data attributes in React

Recently, I downloaded a new app that requires multiple API calls. The first API call retrieves 20 Objects, each with its own unique ID. The second API call is made based on the IDs from the first call. To display this data in my component: <div> ...

Tips for resolving the error message "Uncaught TypeError: Cannot read property '0' of undefined" in React rendering

When I try to map through my list in the render function, it doesn't work, even though it works fine within my component class DesktopList extends Component { constructor(props) { super(props); this.state = { i ...

Guide to setting up a trigger/alert to activate every 5 minutes using Angular

limitExceed(params: any) { params.forEach((data: any) => { if (data.humidity === 100) { this.createNotification('warning', data.sensor, false); } else if (data.humidity >= 67 && data.humidity <= 99.99) { ...

Using Sinonjs fakeserver to handle numerous ajax requests

I utilize QUnit in combination with sinon. Is there a way to make sinon's fakeserver respond to multiple chained ajax calls triggered from the same method? module('demo', { beforeEach: function(){ this.server = sinon.fakeServer. ...

The filter() and some() functions are not producing the anticipated output

Currently, I am in the process of developing a filtering mechanism to sift through a dataset obtained from an API. The array that requires filtering contains objects with various parameters, but my aim is to filter based only on specific parameters. For ...

Utilize the Twitter Bootstrap modal feature to play autoplaying Youtube videos that automatically pause when

Similar Question: How do I halt a video using Javascript on Youtube? I am curious about how I can utilize the modal feature in Twitter Bootstrap to automatically play a Youtube video, and when a user clicks the "close" button, it will cease the video ...

Generate a unique promise with custom functionality using JavaScript bindings in Selenium WebDriver

Is there a specific way to generate a personalized promise within a Selenium WebDriver environment using Node.js? Typically, in a Node.js application, I would produce a promise that encapsulates all of my asynchronous calls like so: return new Promise(fu ...

The function setCustomValidity() will continue to display even after the form has been successfully filled out

My form is very simple and I am trying to validate it using the required attribute: <form name="form"> <label for="Header">Title</label> <input type="text" class="span5" name="Header" ng-model="Message.header" placeholder="Title" on ...

Tips for keeping your button fixed in place

I am encountering an issue where my button moves below the select dropdown list when I try to make a selection. Is there a way to keep the button in place even when the dropdown list from the select box is visible? For reference, here is the current outp ...

Ways to have MongoDB present nested JSON data as an array?

I recently came across some interesting data: { "_id" : ObjectId("5461e16ee7caf96f8f3584a2"), "num_marcacao" : "100", "sexo" : "Fêmea", "idade" : "20", "bigdata" : { "abortos" : [ { "data_aborto" : ...

The sorting feature is not performing as anticipated

I'm dealing with an array of objects fetched from the backend. When mapping and sorting the data in ascending and descending order upon clicking a button, I encountered some issues with the onSort function. The problem lies in the handling of uppercas ...

Travis is experiencing issues with retrieving the API key after logging in with npm

Referencing the information found at , it is stated that an API key should be visible after executing npm login. However, upon performing npm login (or npm adduser) and checking with cat .npmrc, I am unable to locate any indication of an API key. I would ...

Tips for hovering over a link with Webdriver

Currently, for my project, I am utilizing Selenium Webdriver. Successfully automating the functionality to mouse over an image has been achieved. However, there seems to be an issue when attempting to trigger a mouse-over event on a hyperlink using the sam ...

What is the correct way to invoke a static TypeScript class function in JavaScript?

Recently, I encountered a scenario where I have a TypeScript script called test.ts structured like this: class Foo { public static bar() { console.log("test"); } } The requirement was to call this TypeScript function from plain JavaScript ...

Toggle button to create a fade in/out effect

Below is the HTML code snippet: <html> <head> <Script type = "text/javascript" src = "CprMdlrSrch.js"></Script> <link type="text/css"rel="stylesheet"href="CprMdlrSrch.css"/> </head> <body> <div id=" ...