angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

`ng test` should accept argument for karma configuration file

Open traviskaufman opened this issue 10 years ago • 17 comments

As discussed with @hansl, currently there is no way to specify the location of karma.conf.js when running ng test. We should allow this to be specified so that angular-cli can be used with projects that do not place config files in their default locations.

traviskaufman avatar Feb 10 '16 17:02 traviskaufman

Actually the solution would not be argument but a metadata with sensible default. I'll work on this.

hansl avatar Feb 10 '16 17:02 hansl

Does this make a lot of sense given that the file is generated by the CLI and will therefore be in a consistent location?

Brocco avatar Feb 10 '16 17:02 Brocco

Projects might want to move it (e.g. Material2 has it in test/). There should be a way to set its location in the package.json.

hansl avatar Feb 10 '16 17:02 hansl

Point taken. Then I agree we should store the location within package.json Is there a scenario where we would need to support multiple configuration files? I'd prefer to cover all those scenarios up front rather than have multiple ways to store the config info.

Brocco avatar Feb 10 '16 17:02 Brocco

Yeah I'm not 100% sure about multiple test files, but we can revisit.

hansl avatar Feb 10 '16 17:02 hansl

The option --config-file seems to already be there?

--config-file (String) aliases: -c <value>, -cf <value>

riscie avatar Jun 06 '16 22:06 riscie

Although, riscie, those aliases/options do not appear to work.

ghost avatar Dec 08 '16 02:12 ghost

An example scenario for multiple test configs:

  • karma.conf.js - Regular unit tests, run in Phantom or whatever browsers are passed in.
  • karma.browserstack.conf.js - CI-run automated tests against all browsers in our preflight and postflight jobs.

krotscheck avatar Jan 06 '17 18:01 krotscheck

This is something I can take a look at over the next few days.

Brocco avatar Jan 08 '17 02:01 Brocco

Any update?

FJLopezGarcia avatar Jan 13 '17 11:01 FJLopezGarcia

@hansl @Brocco I'm also all for possible multiple config files. I know, I'm always coming up with very specific use cases, but that's all I have :D

As we're using angular-cli in our trainings, we want to be able to run tests normally using

$ ng test

But then there's another testsuite for us training that we want to run to verify our labs are working. So then something like

$ ng test --config-file=foo.config.ts

Would be really need.

@krotscheck 's scenario also seems very valid to me.

0x-r4bbit avatar Jan 28 '17 10:01 0x-r4bbit

An example scenario for multiple test configs:

karma.conf.js - Regular unit tests, run in Phantom or whatever browsers are passed in. karma.browserstack.conf.js - CI-run automated tests against all browsers in our preflight and postflight jobs.

Is this possible still?

codermannn avatar Aug 30 '17 04:08 codermannn

@lohiarahul ng t --config configname.js

kuncevic avatar Aug 30 '17 06:08 kuncevic

@lohiarahul ng t --config configname.js

the build doesn't bundle up the "Alternative Config File" and the CI process fails. Any way to include the other file in the bundle?

codermannn avatar Aug 31 '17 01:08 codermannn

@lohiarahul why want to bundle karma config ?

kuncevic avatar Aug 31 '17 04:08 kuncevic

i have 2 featured modules, which I would like to unit test seperately .

I am using angular-cli , angular 5.

The build will be one , where 2 applications will be shown via the lazy loading .

I want to have seperate testing for these modules. Can some one guide me how to do it ?

AngularTx avatar Apr 10 '18 17:04 AngularTx

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.