Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng test Environment "undefined" does not exist. #9057

Closed
samartioli opened this issue Jan 2, 2018 · 6 comments
Closed

ng test Environment "undefined" does not exist. #9057

samartioli opened this issue Jan 2, 2018 · 6 comments
Labels
area: @angular-devkit/build-angular needs: repro steps We cannot reproduce the issue with the information given

Comments

@samartioli
Copy link

Upgraded to Angular 5.1.2 today as well as to Angular CLI 1.6.3

When I try and run my tests I get the error: Environment "undefined" does not exist.

I can get it to work by providing -e dev, but didn't have to before.

Versions

Angular CLI: 1.6.3
Node: 8.9.1
OS: darwin x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.2
@angular/cli: 1.6.3
@angular/material: 5.0.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Repro steps

ng test

Observed behavior

Environment "undefined" does not exist.

If I run with ng test -e dev my tests run

Desired behavior

Should default to dev as it did previously.

@filipesilva
Copy link
Contributor

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

It's very hard to tell what your project looks like from the information you provided... but if I had to bet it has to do with karma.conf.js. Using the karma config from a new project could help:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

@filipesilva filipesilva self-assigned this Jan 2, 2018
@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jan 2, 2018
@KamelJabber
Copy link

this seems similar to #9058

@halfbeep
Copy link

halfbeep commented Jan 26, 2018

Hi Sam, I get the same issue with my project

ng test
Environment "undefined" does not exist.

I've copied the following files from a newly created (boilerplate) repo where dev is accessible and the error is not happening (filip..all the following files are a new repo):-
.angular-cli.json
tsconfig.json
karma.conf.js
src/test.ts
src/main.ts

Still get the error. Filip, if I go any deeper I'm in my components, classes etc.. surely this error would be quite high in the code ? Any help and sanity appreciated

@halfbeep
Copy link

halfbeep commented Jan 26, 2018

filip, the bug seems to be something todo with karma and @angular/cli the following block is ignored by karma earlier versions:-

angularCli: { environment: 'helloWorld' },

the environment error went away when I upgraded karma to v.1.7.1

npm install [email protected]

@alan-agius4
Copy link
Collaborator

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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/build-angular needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

5 participants