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

ng test should accept customized config parameter of karma.config.js

Open datanglibai opened this issue 5 years ago • 7 comments

Bug Report or Feature Request (mark with an x)


- [x] feature request

Command (mark with an x)


- [x] test

Versions

node v8.10.0 npm 5.6.0 @angular/cli 6.1.3

Repro steps

After upgrade to angular 6, the parameter set for the config of karma.config.js does not work anymore it's NOT the parameter to specify which file, our script is like this

npm run test -- --customizedParam=paramValue

In the karma.config.js, the parameter is used. module.exports = function (config) { var customizedParam= config.customizedParam; ...... }

the npm run test is ng test in package.json this parameter value is decided in build agent, and everytime is different.

The log given by the failure

Unknown option: '--customizedParam' and it stopped the test run

Desired functionality

the command line parameters for karma config can be accepted as before or a workaround. angular 5 cli will also prompt warning message but it didn't stop test and the parameter take effect.

Mention any other details that might be useful

datanglibai avatar Sep 19 '18 04:09 datanglibai

Hi @datanglibai ,

Thanks for the request. We stopped accepting invalid options after 6.0 (deliberately), and this was a known breaking change. I don't think we want to allow custom flags to be passed to karma, but I'll keep this as a feature request.

Thanks!

hansl avatar Oct 02 '18 21:10 hansl

Hello @hansl

I search in documentation, issues and stack overflow but can't find any solution to launch tests from single spec file (fdescribe is not an option) in angular 6+ applications.

In previous versions we use this solution, but for now all unknown --flags are disabled.

You removed this feature, but not offered alternative way. I understand why you block all unknown flags, this is right solution. But also you can add just one more allowed flag (let's say --spec) and this will help to other developers.

EugeneSnihovsky avatar Feb 12 '19 15:02 EugeneSnihovsky

What is status of this? Every time i figure out a way to test a single component, a few months later it breaks.

TomzBench avatar Feb 20 '19 15:02 TomzBench

@chiantia I don't know whether the angular team will solve this issue. For now i write a fast fix for this

EugeneSnihovsky avatar Feb 21 '19 10:02 EugeneSnihovsky

I need this too - should allow a --customFlag

danday74 avatar Apr 11 '19 13:04 danday74

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] avatar Feb 01 '22 18:02 angular-robot[bot]

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

angular-robot[bot] avatar Feb 21 '22 13:02 angular-robot[bot]

Closing as this is not in the Angular CLI roadmap.

A different configuration can be provided using the --karma-config flag.

alan-agius4 avatar Nov 15 '22 13:11 alan-agius4

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.