Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting environment parameter for protractor e2e tests

We are using protractor to test our front end angular app that we are building.

Currently we are using browser.get() to specify our environement we wish to test again(localhost:9000, staging, UAT) however I am wanting to parameterize this so that when we run our tests using grunt test:e2e we can specify a parameter to change the browser.get() to a specified environment.

Something like being able to call grunt test:e2e NODE_ENV=uat to test against specified environment.

Anyone have any insight to how to do this?

like image 382
user249656 Avatar asked May 20 '15 18:05

user249656


1 Answers

You can pass any number of arguments to protractor You need to pass parameters within the protractor task in your grunt file. Here is small snippet

config: grunt.file.readJSON('config-param.json'),
protractor: {
        options: {
            configFile: "config/e2e.conf.js", // Default config file
            keepAlive: true, // If false, the grunt process stops when the test fails. 
            noColor: false, // If true, protractor will not use colors in its output.
            debug: '<%= config.debugger %>',
            args: {
                params: '<%= config %>'
            }
        },
        run: {}
    },

and you can access parameters in your specs like. browser.params.fieldName

like image 104
Hasan Avatar answered Sep 23 '22 09:09

Hasan