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

added debug argument to ng test task. #1799

Closed
wants to merge 14 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@abner
Contributor

abner commented Aug 22, 2016

added debug argument to ng test task. This argument when passed disable instrumentation and coverage, allowing to debug the source code when running tests. Fixes #1798


This change is Reviewable

abner added some commits Aug 22, 2016

added debug argument to (node:23405) fs: re-evaluating native module …
…sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

�[2K�[1G�[?25h�[2K�[1G�[?25hYou have to be inside an angular-cli project in order to use the test command.. This argument when passed disable instrumentation and coverage, allowing to debug the source code when running tests
added debug argument to ng test task. This argument when passed disab…
…le instrumentation and coverage, allowing to debug the source code when running tests

@googlebot googlebot added the cla: yes label Aug 22, 2016

abner added some commits Aug 22, 2016

added debug argument to test task. This argument when passed disable …
…instrumentation and coverage, allowing to debug the source code when running tests
@abner

This comment has been minimized.

Show comment
Hide comment
@abner

abner Aug 23, 2016

Contributor

@filipesilva I added this pull request to solve an issue related to not being able to see application code in debug karma session because of the instrumentation made to report the coverage. Basically i added a debug argument to ng test (ng test debug) which disable coverage and instrumentation parts and this way i could see my application code in chrome developer tool debug.
Could you review this and see if it would be merged.
Thanks in advance!

Contributor

abner commented Aug 23, 2016

@filipesilva I added this pull request to solve an issue related to not being able to see application code in debug karma session because of the instrumentation made to report the coverage. Basically i added a debug argument to ng test (ng test debug) which disable coverage and instrumentation parts and this way i could see my application code in chrome developer tool debug.
Could you review this and see if it would be merged.
Thanks in advance!

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Aug 23, 2016

Member

Before I review, can I ask you to test in the latest master? We had a problem with sourcemaps that is fixed I believe, and would cause you to see instrumented code.

@TheLarkInn can you have a look at #1798 and tell me if this is the sourcemaps issue?

Member

filipesilva commented Aug 23, 2016

Before I review, can I ask you to test in the latest master? We had a problem with sourcemaps that is fixed I believe, and would cause you to see instrumented code.

@TheLarkInn can you have a look at #1798 and tell me if this is the sourcemaps issue?

@TheLarkInn

This comment has been minimized.

Show comment
Hide comment
@TheLarkInn

TheLarkInn Aug 23, 2016

Member

No this is specifically related to instrumented code in testing mode.

Member

TheLarkInn commented Aug 23, 2016

No this is specifically related to instrumented code in testing mode.

@abner

This comment has been minimized.

Show comment
Hide comment
@abner

abner Aug 24, 2016

Contributor

I reviewed and it still occurs. As @TheLarkInn said it is related to instrumented code.

Contributor

abner commented Aug 24, 2016

I reviewed and it still occurs. As @TheLarkInn said it is related to instrumented code.

@abner

This comment has been minimized.

Show comment
Hide comment
@abner

abner Sep 17, 2016

Contributor

hi @TheLarkInn and @filipesilva !
I still need this feature in angular-cli. I updated the pull request with master.
Could you guys check if it would be merged?
Thanks in advance.

Contributor

abner commented Sep 17, 2016

hi @TheLarkInn and @filipesilva !
I still need this feature in angular-cli. I updated the pull request with master.
Could you guys check if it would be merged?
Thanks in advance.

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Sep 22, 2016

Member

@abner I'm sorry it's taken so long to review this PR. I've bumped the original issue as something that needs to be finished for RC1 and we should get to it soon.

Member

filipesilva commented Sep 22, 2016

@abner I'm sorry it's taken so long to review this PR. I've bumped the original issue as something that needs to be finished for RC1 and we should get to it soon.

@abner

This comment has been minimized.

Show comment
Hide comment
@abner

abner Sep 22, 2016

Contributor

great @filipesilva . I just updated the branch.

Contributor

abner commented Sep 22, 2016

great @filipesilva . I just updated the branch.

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Oct 3, 2016

Member

CI is showing a lint error:

/home/travis/build/angular/angular-cli/packages/angular-cli/models/webpack-build-test.js
  9:7  error  'debug' is already defined  no-redeclare

It's minor but I cannot merge it without a green CI.

Member

filipesilva commented Oct 3, 2016

CI is showing a lint error:

/home/travis/build/angular/angular-cli/packages/angular-cli/models/webpack-build-test.js
  9:7  error  'debug' is already defined  no-redeclare

It's minor but I cannot merge it without a green CI.

@@ -5,6 +5,7 @@ import {CliConfig} from '../models/config';
const NgCliTestCommand = TestCommand.extend({
availableOptions: [
{ name: 'watch', type: Boolean, default: true, aliases: ['w'] },
{ name: 'debug', type: Boolean, default: false, aliases: ['d'] },

This comment has been minimized.

@filipesilva

filipesilva Oct 3, 2016

Member

How is this option being passed into the karma config? I don't think it's being passed in yet.

My suggestion is this: in karma.conf.js add in the debug property to the angularCli options:

    angularCli: {
      config: './angular-cli.json',
      environment: 'dev',
      debug: false
    },

Then you'll need to also change packages/angular-cli/tasks/test.ts to set this to true in the options variable that's being passed into karma.Server.

Make sure it works though, this is the kind of thing I don't know we can really do CI tests without doing really weird stuff.

@filipesilva

filipesilva Oct 3, 2016

Member

How is this option being passed into the karma config? I don't think it's being passed in yet.

My suggestion is this: in karma.conf.js add in the debug property to the angularCli options:

    angularCli: {
      config: './angular-cli.json',
      environment: 'dev',
      debug: false
    },

Then you'll need to also change packages/angular-cli/tasks/test.ts to set this to true in the options variable that's being passed into karma.Server.

Make sure it works though, this is the kind of thing I don't know we can really do CI tests without doing really weird stuff.

This comment has been minimized.

@abner

abner Oct 4, 2016

Contributor

i actually implemented debug false as default so it doesn't need to be passed. i added an argument to the test command --debug (-d). I think we would add a npm script npm run test:debug which would call ng test --debug

@abner

abner Oct 4, 2016

Contributor

i actually implemented debug false as default so it doesn't need to be passed. i added an argument to the test command --debug (-d). I think we would add a npm script npm run test:debug which would call ng test --debug

This comment has been minimized.

@filipesilva

filipesilva Oct 4, 2016

Member

I was tracing back the code and realize you are right. Since we just start karma with all the options that the command receives, the debug property will be there. My bad!

@filipesilva

filipesilva Oct 4, 2016

Member

I was tracing back the code and realize you are right. Since we just start karma with all the options that the command receives, the debug property will be there. My bad!

@@ -66,7 +67,7 @@ const getWebpackTestConfig = function (projectRoot, environment, appConfig) {
{ test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000' },
{ test: /\.html$/, loader: 'raw-loader', exclude: [path.resolve(appRoot, appConfig.index)] }
],
postLoaders: [
postLoaders: debug ? [] : [

This comment has been minimized.

@filipesilva

filipesilva Oct 3, 2016

Member

In the latest webpack update, the loader configs changed a bit and is now a single rules array.

You're probably going to have to add the sourcemap-istanbul-instrumenter-loader conditionally, but by itself, at the end.

@filipesilva

filipesilva Oct 3, 2016

Member

In the latest webpack update, the loader configs changed a bit and is now a single rules array.

You're probably going to have to add the sourcemap-istanbul-instrumenter-loader conditionally, but by itself, at the end.

This comment has been minimized.

@abner

abner Oct 3, 2016

Contributor

ok @filipesilva . i will update this branch to the latest changes in master and fix the linting issue you mentioned.

@abner

abner Oct 3, 2016

Contributor

ok @filipesilva . i will update this branch to the latest changes in master and fix the linting issue you mentioned.

const appRoot = path.resolve(projectRoot, appConfig.root);
var debug = typeof debug !== 'undefined' ? debug : false;

This comment has been minimized.

@filipesilva

filipesilva Oct 3, 2016

Member

Linting says this variable is being shadowed.

@filipesilva

filipesilva Oct 3, 2016

Member

Linting says this variable is being shadowed.

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Oct 14, 2016

Member

@abner we were talking about this PR between the team, and thinking of a somewhat alternative solution.

How about having a --code-coverage (-cc) flag that adds the instrumentation, instead of having a --debug flag to disable it? I don't think users care about code coverage during their normal watch cycle, and it should make things faster as well.

What do you think?

Member

filipesilva commented Oct 14, 2016

@abner we were talking about this PR between the team, and thinking of a somewhat alternative solution.

How about having a --code-coverage (-cc) flag that adds the instrumentation, instead of having a --debug flag to disable it? I don't think users care about code coverage during their normal watch cycle, and it should make things faster as well.

What do you think?

@filipesilva filipesilva self-assigned this Oct 14, 2016

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 23, 2016

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 23, 2016

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Oct 23, 2016

Member

Heya @abner, I ran with the idea of making code coverage optional, and also made linting optional in #2840.

Member

filipesilva commented Oct 23, 2016

Heya @abner, I ran with the idea of making code coverage optional, and also made linting optional in #2840.

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 23, 2016

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 23, 2016

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 23, 2016

filipesilva added a commit that referenced this pull request Oct 24, 2016

feat(test): make code coverage and lint optional (#2840)
Heavily inspired by @abner's work on #1799.

Partially address #1980
Close #1799

@lathonez lathonez referenced this pull request Mar 28, 2017

Open

Add Test Coverage #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment