Search code examples
javascripttestingcommand-line-argumentsprotractortest-suite

protractor - send spec/suite name as parameter


can I run protractor tests with spec or suite name as a parameter? I'm currently running it with:

protractor myconf.js 

thanks.


Solution

  • Yes, there is the specific --specs command-line argument:

    $ protractor --help
    Usage: protractor [options] [configFile]
    configFile defaults to protractor.conf.js
    The [options] object will override values from the config file.
    Options:
      --help                                             Print Protractor help menu                               
      --version                                          Print Protractor version         
    ...
      --specs                                            Comma-separated list of files to test  
    

    You would still need a config to be passed, but --specs would override the specs set in the configuration:

    protractor myconf.js --specs=test/e2e/myspec.js
    

    You can also use the --suite command-line argument:

    protractor myconf.js --suite=smoke
    

    where smoke matches the configured suite name:

    suites: {
      smoke: 'spec/smoketests/*.js',
      full: 'spec/*.js'
    },
    

    Alternatively, if you are using jasmine2, you can make use of the "focused tests" feature by temporarily changing describe to fdescribe and/or it to fit.