Angular-cli: Entry for test is ignored when using ng test --app

Created on 15 Jun 2017  路  9Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.1.1
node: 6.10.0
os: win32 x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.1.1
@angular/compiler-cli: 4.1.3
@angular/language-service: 4.1.3

Repro steps.

  1. ng new some-project
  2. Add a new application to .angular-cli.json and change the test entry values.
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "some-project"
  },
  "apps": [
    {
      "root": "src",
      "name": "first",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "first.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    },
    {
      "root": "src",
      "name": "second",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "second.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }    
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}
  1. Execute ng test --app second

The log given by the failure.

ERROR in Entry module not found: Error: Can't resolve 'd:\temp\newcli\one-six\src\first.ts' in 'd:\temp\newcli\one-six\node_modules\@angular\cli\models\webpack-configs'

Since neither first.ts or second.ts exists, I would expect the error to indicate second.ts was not found. Even if I add the files, only first.ts is used.

Desired functionality.


The entry file for test when using multiple apps should be honored.

Mention any other details that might be useful.

2 (required) broken

Most helpful comment

Problem seems to be here:
https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/webpack-configs/test.ts#L22

My current workaround is changing the karma.conf.js, and adding

var cliConfig = require('@angular/cli/models/config');
var _fromProject = cliConfig.CliConfig.fromProject;

cliConfig.CliConfig.fromProject = function() {
    var cfp = _fromProject.apply(this, arguments);
    var app = cfp.config.apps.filter(function(app) { return app.name === config.angularCli.app; })[0];
    if(app!=null){
       ix = cfp.config.apps.indexOf(app);
       if(ix>0){
         cfp.config.apps[ix] = cfp.config.apps[0];
         cfp.config.apps[0] = app;
       }
    }
    return cfp;
}

before the config.set call.

Not the cleanest, but it works.

All 9 comments

Problem seems to be here:
https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/webpack-configs/test.ts#L22

My current workaround is changing the karma.conf.js, and adding

var cliConfig = require('@angular/cli/models/config');
var _fromProject = cliConfig.CliConfig.fromProject;

cliConfig.CliConfig.fromProject = function() {
    var cfp = _fromProject.apply(this, arguments);
    var app = cfp.config.apps.filter(function(app) { return app.name === config.angularCli.app; })[0];
    if(app!=null){
       ix = cfp.config.apps.indexOf(app);
       if(ix>0){
         cfp.config.apps[ix] = cfp.config.apps[0];
         cfp.config.apps[0] = app;
       }
    }
    return cfp;
}

before the config.set call.

Not the cleanest, but it works.

I am encountering this issue as well. I see that @Bobdina committed a PR but never signed the agreement.
Would it be possible for this few lines of code to somehow still end up in the codebase?

@EdwinMeijne
Well, I did sign the cla, but apparently my checkins are registered under a different (fake) email address than the one I used to sign. I'm not a git expert, and I looked up how to fix it, but it seemed quite complicated at the time (I recall having to rewrite your entire git version history?). I gave up then and there, hoping someone else would pick this up.

The changeset is like 2 lines of code (smaller than the workaround), so of course anyone is free to retry that same commit properly.

is this issue fixed?

We decided we would want to test all code when doing changes, as our plan is to create 10+ apps within the same repository which mostly share library code and the core redux store. So didn't investigate further.

The issue still exists in Angular CLI 1.6.5.

any updates on this issues ?

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

burdzand picture burdzand  路  100Comments

zpydee picture zpydee  路  102Comments

adwd picture adwd  路  173Comments

elvisbegovic picture elvisbegovic  路  100Comments

beeman picture beeman  路  95Comments