Search code examples
javascriptangularjsgruntjsprotractorend-to-end

How to run single e2e test with grunt and protractor


I'm assuming this is possible and actually pretty simple, but I'm new to both grunt and protractor and I was not able to find the answer online (maybe I used wrong search criteria).

I have the following e2e test in file test/e2e/Recipients.js:

describe('Recipients Tab', function() {

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

    it('should have no e-mail list', function () {
        expect(element(by.css('accordion')).isPresent()).toBe(false);
    });
});

Currently, I'm doing this:

grunt e2e

My protractor config file:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    capabilities: {
        'browserName': 'chrome'
    },
    specs: ['../e2e/**/*.js'],
    baseUrl : 'http://localhost:8080/spr',

    jasmineNodeOpts: {
        showColors: true // Use colors in the command line report.
    }
};

Of course this runs all my tests, but while I'm developing a specific test, I don't want to run the entire battery of tests. I want to run this one file.

How can I do that? Is there any flag or something?

Thanks


Solution

  • You just have to pass the specs option to the protractor CLI. The specs option expects a comma-separated list of JS files to run.

    You'll need to edit your Gruntfile.js to pass this option to protractor.