Skip to content

feat(test): Add --config-file flag option to ng test command #1102

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

Closed
wants to merge 1 commit into from
Closed

feat(test): Add --config-file flag option to ng test command #1102

wants to merge 1 commit into from

Conversation

marc-sensenich
Copy link
Contributor

@marc-sensenich marc-sensenich commented Jun 16, 2016

Allow for users to optionally specify a path to a karma config file on the ng test command which
will allow for the usage of a karma config file different from that set as the default in the
angular-cli.json file

Fixes: #976

@Brocco
Copy link
Contributor

Brocco commented Jun 16, 2016

I don't feel this is the correct approach to handle this scenario... I think the option to define the location of a default config file should be set within the angular-cli.json file so devs won't have to pass in a path on every run of ng test.

Also, prior to merging this will need to be consolidated down to a single commit.

@marc-sensenich
Copy link
Contributor Author

I agree with you on that, and that behavior will remain the same for identifying the default path for the karma config file. This optional flag will give the developer the option to specify a path for different karma config file when using npm test.

@ValeryVS
Copy link
Contributor

Having an option in angular-cli.json is right.
Flag for ng-test is also usable.
For example, I want to run tests with chrome and firefox launchers and only with phantomjs.
Of course, it can be done by looking to process.args in karma.config...

@Brocco
Copy link
Contributor

Brocco commented Oct 14, 2016

Please update this PR after rebasing on latest master

@marc-sensenich
Copy link
Contributor Author

@Brocco for this feature merge, are you expecting for the dev to define for example a staging environment test file and they could then define that in their project config file as follows: test.karma.staging which would then define the path to their staging configuration file for Karma? This would then eliminate the need for them to pass the path each time and the flag could be used as --config staging

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@googlebot
Copy link

CLAs look good, thanks!

The config flag on the `ng test` command allows for users to refer to a different configuration
file for Karma based on the path in the config flag.
@marc-sensenich
Copy link
Contributor Author

marc-sensenich commented Nov 25, 2016 via email

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little nit. I like this approach more than the e2e. Also, make sure to use the proper path separator in Windows.

return ng('test', '--single-run')
.then(() => ng('test', '--watch=false'));
.then(() => ng('test', '--watch=false'))
.then(() => ng('test', '--watch=false', `--config=${karmaConfigPath}`));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to have a test for an alternative configuration, not just the default one.

@filipesilva
Copy link
Contributor

#4564 got merged meanwhile. Sorry it wasn't your PR instead, which was much older :/

@vinaymavi
Copy link

vinaymavi commented Nov 22, 2018

As per CLI help, right command is ng test --karma-config=karma.conf.js

CLI Help screenshot:

screen shot 2018-11-22 at 12 47 58 pm

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] ng e2e --config-file parameter
7 participants