webdriverio-boneyard / wdio-cucumber-framework

A WebdriverIO v4 plugin. Adapter for Cucumber testing framework.
MIT License
77 stars 61 forks source link

globbing in --spec causes "more than one config file specified" error #169

Closed worc closed 5 years ago

worc commented 5 years ago

if i set a globbed spec ./src/**/*.feature in the config file or specify a single file through the cli ./src/login.feature tests run just fine:

exports.config = {
  specs: ['./test/features/**/*.feature', './src/**/*.feature']
}

or

yarn run wdio ./wdio.conf.js --spec ./src/some-specific-tests.feature

but if i use a glob in the cli option, the glob expands correctly, but the cli prints its help menu and then throws an unrelated error:

yarn run wdio ./wdio.conf.js --spec ./src/**/*.feature
wdio ./wdio.conf.js --spec <a long list of features>

WebdriverIO CLI runner

Usage: wdio [options] [configFile]
Usage: wdio config
Usage: wdio repl [browserName]
config file defaults to wdio.conf.js
The [options] object will override values from the config file.
An optional list of spec files can be piped to wdio that will override configured specs.

Options:
  --help, -h            prints WebdriverIO help menu
  --version, -v         prints WebdriverIO version
  --host                Selenium server host address
  --port                Selenium server port
  --path                Selenium server path (default: /wd/hub)
  --user, -u            username if using a cloud service as Selenium backend
  --key, -k             corresponding access key to the user
  --watch               watch specs for changes
  --logLevel, -l        level of logging verbosity (default: silent)
  --coloredLogs, -c     if true enables colors for log output (default: true)                                                                        [default: true]
  --bail                stop test runner after specific amount of tests have failed (default: 0 - don't bail)
  --screenshotPath, -s  saves a screenshot to a given path if a command fails
  --baseUrl, -b         shorten url command calls by setting a base url
  --waitforTimeout, -w  timeout for all waitForXXX commands (default: 1000ms)
  --framework, -f       defines the framework (Mocha, Jasmine or Cucumber) to run the specs (default: mocha)
  --reporters, -r       reporters to print out the results on stdout
  --suite               overwrites the specs attribute and runs the defined suite
  --spec                specifies spec file(s) to run or filter(s) for specs defined in the specs attribute
  --exclude             specifies spec file(s) to exclude from the run
  --cucumberOpts.*      Cucumber options, see the full list options at https://github.com/webdriverio/wdio-cucumber-framework#cucumberopts-options
  --jasmineNodeOpts.*   Jasmine options, see the full list options at https://github.com/webdriverio/wdio-jasmine-framework#jasminenodeopts-options
  --mochaOpts.*         Mocha options, see the full list options at http://mochajs.org

Error: Error: more than one config file specified
PFaz540 commented 5 years ago

I don't think this is specific to the cucumber service, as I'm getting this in my wdio project (I'm using the mocha service)

I posted this in the WebdriverIO Gitter:

The below works as expected, the baseUrl in my config is replaced by whatever I use in CLI.

./node_modules/.bin/wdio config/desktop.conf.js --baseUrl https://www.google.co.uk

But if I have a script in my package.json that is:

"test:desktop": "./node_modules/.bin/wdio config/desktop.conf.js"

And I write the below in terminal, it errors mentioning multiple config files being used.

npm run test:desktop --baseUrl https://www.google.co.uk
More than one config file was specified: config/desktop.conf.js, https://www.google.co.uk
Error: You can only run one wdio config file!

Is this a bug or expected behaviour? I'm more than happy to raise this as an issue.

WillBrock commented 5 years ago

@PFaz540 When using npm run you need to specify -- before you start your argument list.

e.g. npm run test:desktop -- --baseUrl https://www.google.co.uk

worc commented 5 years ago

this should still be open. this is a bug with yarn not npm... :/

christian-bromann commented 5 years ago

this is a bug with yarn not npm... :/

Why is this a bug with yarn? And even if it would be why should this still be open then?

markbirbeck commented 5 years ago

This also seems to happen if you do:

wdio --spec test/*.js mocha.wdio.conf.js

So I don't think it's anything to do with Yarn or NPM.

mjhenkes commented 5 years ago

The issue here is that your shell is expanding the glob, not wdio. Try quoting your string:

yarn run wdio ./wdio.conf.js --spec './src/**/*.feature'

https://medium.com/@jakubsynowiec/you-should-always-quote-your-globs-in-npm-scripts-621887a2a784

Does the --spec cli option support globs?