x)- [ ] bug report -> please search issues before submitting
- [x] feature request
@angular/cli: 1.0.0
node: 7.7.4
This is a proposal to make _multiple applications_ use-case more useful.
Currently, ng build and ng test support an --app option to choose a specific application from apps property in the CLI options. but karma.config.js is accepted at the root test property.
Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "multiple-apps"
},
"apps": [
{
"name": "main",
...
"test": "src/main/test.ts"
},
{
"name": "admin",
...
"test": "src/admin/test.ts"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
}
There is no way to know which app is chosen in karma.conf.js.
Each application config should accept its own karma option. and root test.karma property will be a default configuration for karma-undefined apps.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "multiple-apps"
},
"apps": [
{
"name": "main",
...
"test": "src/main/test.ts"
},
{
"name": "admin",
...
"test": "src/admin/test.ts",
"karma": "./karma.conf.admin.js"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
}
lint and e2e have the same situation.
Alternative approach
"apps": [{
"name": "admin",
...
"test": {
"entry": "src/admin/test.ts",
"tsconfig": "src/admin/tsconfig.spec.json",
"karma": "karma.conf.admin.js"
}
}]
In the interest of backwards compatibility, I'd recommend having a test entry inside each app that overrides/merges with the root one if present.
{
"apps": [
{
"name": "main",
...
"test": {
"karma": {
"config": "./karma.conf.1.js"
}
},
},
{
"name": "admin",
...
"test": {
"karma": {
"config": "./karma.conf.2.js"
}
},
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
}
@laco0416
I find out this problem solution!
"test"value it just string
(each app test.ts path)
in angular-cli.json file
you change karma.conf.js
```
module.exports = function (config) {
let _cliAppProcessors ={};
_cliAppProcessors[config.angularCli.app+'/test.ts'] = ['@angular/cli'];
config.set({
//...
preprocessors: _cliAppProcessors,
````
it's done!!!
Hi @YuJM, I followed your suggestion above, but it's still running tests in every app. I would expect it to run only tests in the specified app.
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
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._
Most helpful comment
In the interest of backwards compatibility, I'd recommend having a
testentry inside each app that overrides/merges with the root one if present.