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

[feature]egg-bin cov support nyc params #2815

Closed
yinseny opened this issue Jul 17, 2018 · 7 comments
Closed

[feature]egg-bin cov support nyc params #2815

yinseny opened this issue Jul 17, 2018 · 7 comments

Comments

@yinseny
Copy link

yinseny commented Jul 17, 2018

  • Node Version: 8.11.2
  • Egg Version: 2.9.1
  • Plugin Name: egg-bin
  • Plugin Version: 4.7.1
  • Platform: win64
  • Mini Showcase Repository:

We want to enable mocha & nyc's teamcity reporter to show test cases & coverage in our teamcity build server.
We've added teamcity support for mocha using:

  "scripts": {
    "cov": "egg-bin cov --reporter=mocha-teamcity-reporter"
  }

But for nyc, we found nyc's params are fixed in egg-bin, we are not able to pass anything to it.

  getCovArgs(context) {
    let covArgs = [
      // '--show-process-tree',
      '--temp-directory', './node_modules/.nyc_output',
      '-r', 'text-summary',
      '-r', 'json-summary',
      '-r', 'json',
      '-r', 'lcov',
    ];
    ...
    return covArgs;
  }

We've tried add additional reporter in .nycrc or package.json files, but they all got overwritten by the fixed params.
Please help check if there's any way we can enable teamcity reporter for nyc.

@yinseny yinseny changed the title egg-bin cov support nyc params [feature]egg-bin cov support nyc params Jul 17, 2018
@atian25
Copy link
Member

atian25 commented Jul 18, 2018

@atian25 atian25 closed this as completed Jul 18, 2018
@yinseny
Copy link
Author

yinseny commented Jul 18, 2018

We've tried add additional reporter in .nycrc or package.json files, but they all got overwritten by the fixed params.

doesn't work, it will be force overwrite by the params provided by egg-bin

@atian25 atian25 reopened this Jul 18, 2018
@atian25
Copy link
Member

atian25 commented Jul 18, 2018

right now, all args pass to egg-bin test/cov is passthrough to mocha.

maybe we could add some logic at getCovArgs to read package.json.

PR is welcome

@atian25
Copy link
Member

atian25 commented Jul 18, 2018

or check whether .nyc is exists, then getCovArgs do nth

@yinseny
Copy link
Author

yinseny commented Jul 18, 2018

seems when same key exists in both .nycrc & command line instruments, nyc will prefer the instruments.

This makes "reporter" & "exclude" keys in .nycrc being ignored because egg-bin always call nyc with -r & -x.

For -x, since egg-bin already support passing -x to nyc, i don't see the point for changing logic for it.

For -r, i'm considering a more generic approach:
maybe we can make cov support passing args to nyc as well. we can define an arg format like --nyc-xxx. then in cov.js we just remove the --nyc and pass -xxx to nyc. this could also make the experience consistent as we are controlling mocha & nyc args together in cov command.
I'll try create a pr for this, let me know your thoughts on this.

check whether .nyc is exists, then getCovArgs do nth.

this might break all the '-x' logic currently implemented in test/cov

@atian25
Copy link
Member

atian25 commented Jul 18, 2018

sure, PR is welcome.

@yinseny
Copy link
Author

yinseny commented Jul 24, 2018

pr is done, please help review. thx.
feat(cov): add nyc instrument passthrough

@atian25 atian25 closed this as completed Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants