Skip to content

Proposal: app-specific karma config #6008

@lacolaco

Description

@lacolaco

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Versions.

@angular/cli: 1.0.0
node: 7.7.4

Problem

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.

Solution

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"
    }
  },
}

Note

lint and e2e have the same situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort1: easy (hours)featureIssue that requests a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions