Angular-cli: "ng e2e --prod" fails

Created on 18 May 2018  ยท  3Comments  ยท  Source: angular/angular-cli

Versions

Angular CLI: 6.0.3                                                                                                                                          โ”‚
Node: 10.0.0                                                                                                                                                โ”‚
OS: linux x64                                                                                                                                               โ”‚
Angular: 6.0.2                                                                                                                                              โ”‚
... animations, common, compiler, compiler-cli, core, forms                                                                                                 โ”‚
... http, language-service, platform-browser                                                                                                                โ”‚
... platform-browser-dynamic, router                                                                                                                        โ”‚
                                                                                                                                                            โ”‚
Package                           Version                                                                                                                   โ”‚
-----------------------------------------------------------                                                                                                 โ”‚
@angular-devkit/architect         0.6.3                                                                                                                     โ”‚
@angular-devkit/build-angular     0.6.3                                                                                                                     โ”‚
@angular-devkit/build-optimizer   0.6.3                                                                                                                     โ”‚
@angular-devkit/core              0.6.3                                                                                                                     โ”‚
@angular-devkit/schematics        0.6.3                                                                                                                     โ”‚
@angular/cli                      6.0.3                                                                                                                     โ”‚
@ngtools/webpack                  6.0.3                                                                                                                     โ”‚
@schematics/angular               0.6.3                                                                                                                     โ”‚
@schematics/update                0.6.3                                                                                                                     โ”‚
rxjs                              6.1.0                                                                                                                     โ”‚
typescript                        2.7.2                                                                                                                     โ”‚
webpack                           4.8.3                                                                                                                     โ”‚

Repro steps

  • Step 1: create a new app with ng new its-a-test-app
  • Step 2 run e2e tests normally with ng e2e
  • Step 3 run e2e tests against production configuration ng e2e --prod

Observed behavior

Configuration 'production' could not be found in project 'its-a-test-e2e'.
Error: Configuration 'production' could not be found in project 'its-a-test-e2e'.
    at Architect.getBuilderConfiguration (/tmp/its-a-test/node_modules/@angular-devkit/architect/src/architect.js:102:23)
    at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (/tmp/its-a-test/node_modules/@angular/cli/models/architect-command.js:64:55)
    at MergeMapSubscriber._tryNext (/tmp/its-a-test/node_modules/rxjs/internal/operators/mergeMap.js:122:27)
    at MergeMapSubscriber._next (/tmp/its-a-test/node_modules/rxjs/internal/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/tmp/its-a-test/node_modules/rxjs/internal/Subscriber.js:103:18)
    at TapSubscriber._next (/tmp/its-a-test/node_modules/rxjs/internal/operators/tap.js:109:26)
    at TapSubscriber.Subscriber.next (/tmp/its-a-test/node_modules/rxjs/internal/Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (/tmp/its-a-test/node_modules/rxjs/internal/operators/mergeMap.js:141:26)
    at InnerSubscriber._next (/tmp/its-a-test/node_modules/rxjs/internal/InnerSubscriber.js:30:21)
    at InnerSubscriber.Subscriber.next (/tmp/its-a-test/node_modules/rxjs/internal/Subscriber.js:103:18)                                                                         

Desired behavior

ng e2e --prod --aot should run the e2e tests against the production, AOT-compiled build of the application. I had an issue solely on production/AOT, so I would like to test against this configuration.

Most helpful comment

You can add a configuration for e2e that runs against the production dev server:

"project-name-e2e": {
  "root": "e2e/",
  "projectType": "application",
  "architect": {
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "e2e/protractor.conf.js",
        "devServerTarget": "project-name:serve"
      },
      "configurations": {
        "production": {
          "devServerTarget": "project-name:build:production"
        }
      }
    },

This question has come up a couple of times so far though. I'll add it to the default schematics.

All 3 comments

You can add a configuration for e2e that runs against the production dev server:

"project-name-e2e": {
  "root": "e2e/",
  "projectType": "application",
  "architect": {
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "e2e/protractor.conf.js",
        "devServerTarget": "project-name:serve"
      },
      "configurations": {
        "production": {
          "devServerTarget": "project-name:build:production"
        }
      }
    },

This question has come up a couple of times so far though. I'll add it to the default schematics.

thanks @filipesilva ! just a note, i had to change "devServerTarget": "project-name:build:production" to "devServerTarget": "project-name:serve:production" (build -> serve).

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

gotschmarcel picture gotschmarcel  ยท  3Comments

MateenKadwaikar picture MateenKadwaikar  ยท  3Comments

NCC1701M picture NCC1701M  ยท  3Comments

delasteve picture delasteve  ยท  3Comments

IngvarKofoed picture IngvarKofoed  ยท  3Comments