Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress as a node module and multireporters #1357

Closed
Konstruktour opened this issue Feb 21, 2018 · 3 comments · Fixed by #2224
Closed

Cypress as a node module and multireporters #1357

Konstruktour opened this issue Feb 21, 2018 · 3 comments · Fixed by #2224
Milestone

Comments

@Konstruktour
Copy link

Konstruktour commented Feb 21, 2018

  • Operating System: Windows 10
  • Cypress Version: 2.02
  • Browser Version: Headless

Is this a Feature or Bug?

Bug

Current behavior:

Using cypress as a node module and passing a config object including a string with a comma results in unexpected behaviour. String including commas is split up and passed as additional properties.

How to reproduce:

Using for eg a multireporter and calling the cypress runner in a nodejs script.

cypress.run({
    reporter: 'mocha-multi-reporters',
    reporterOptions: {
        reporterEnabled: 'JSON, Spec',
        jsonReporterOptions: {
            toConsole: true
        },
    }
};

which calls the run function in lib/cypress.js.
After line 22
options = util.normalizeModuleOptions(options);
the passed options object is transformed to
reporter: 'mocha-multi-reporters', reporterOptions: 'reporterEnabled=JSON, Spec,jsonReporterOptions=[object Object]'

which results in the wrong object (eg at open_project.js, function create)

...
     reporter: 'mocha-multi-reporters',
     reporterOptions: 
      { reporterEnabled: 'JSON',
        Spec: undefined,
        jsonReporterOptions: 'object Object'
     }
...

'Spec' is not part of the property reporterEnabled anymore. Also the jsonReporterOptions is not resolved correctly.
The multireporter cannnot handle this wrong object and runs only one reporter.

@brian-mann
Copy link
Member

Yup this is a bug. The problem is that all of the args have to be serialized into the command line. We'll have to rethink this approach or update our arg serializer / deserializer.

@brian-mann
Copy link
Member

Related to: #1348

@Konstruktour
Copy link
Author

Konstruktour commented Feb 22, 2018

maybe connected: when using a configFile (loaded through plugin as described here https://docs.cypress.io/api/plugins/configuration-api.html#Promises ) which contains nested objects like

{
  "reporter": "mocha-multi-reporters",
  "reporterOptions": {
    "reporterEnabled": "mocha-junit-reporter  Spec",
    "mochaJunitReporterReporterOptions": {
      "mochaFile": "./reports/report.xml"
    }
  }
}

results in an error

Cannot set property 'mochaFile' of undefined
TypeError: Cannot set property 'mochaFile' of undefined
    at node_modules\cypress\dist\Cypress\resources\app\packages\server\lib\config.js:275:37

brian-mann added a commit that referenced this issue Jul 29, 2018
…as command line arguments

- this avoids needing our own serializer for nested objects such as
reporterOptions, config.hosts or config.blacklistHosts
- prevent adding additional underscored properties when propagating
arguments to electron
@brian-mann brian-mann added this to the 3.0.3 milestone Jul 30, 2018
brian-mann pushed a commit that referenced this issue Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants