Angular-cli: `ng e2e --environment=foo` doesn't work as expected

Created on 24 Feb 2017  路  9Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Mac OSX Sierra

Versions.

@angular/cli: 1.0.0-beta.32.3
node: 6.9.5
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Repro steps.

ng new my-app; cd my-app; ng e2e --environment=prod

Most helpful comment

Hello,

and how we will make e2e tests for all the different environments that we have if it accepts by default only the enviroment.ts?

All 9 comments

Can you provide some additional information?What are you expecting and what is actually happening?

@clydin I'm importing environment in e2e tests like this:

import { environment } from '../src/environments/environment';
console.log(environment);

and expect the actual environment imported to depend on --environment flags

@tsabirgaliev environment replacement only works in your app and unit tests. e2e tests are their own separate app, outisde webpack, and do not support that feature.

Hello,

and how we will make e2e tests for all the different environments that we have if it accepts by default only the enviroment.ts?

I confirm: ng e2e works with -e or --environment flag with CLI in version 1.5.5.

The e2e docs state

Please note that options that are supported by ng serve are also supported by ng e2e

And from the serve docs

--environment (aliases: -e)
Defines the build environment.

But when I do ng e2e --environment prod he is still picking up the test environment. It looks like the CLI is checking but ignoring it since

ng e2e --environment whatever
Environment "whatever" does not exist.

IMHO its working partly. The server is starting and providing the environment to the app but it is not available in e2e tests.

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

donaldallen picture donaldallen  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

hareeshav picture hareeshav  路  3Comments