Skip to content

Run ng test in prod mode ng test --prod #11606

Closed

Description

@boldwade

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node: 8.9.4
npm: 6.1.0
ng: 6.0.4

Repro steps

ng test --prod

The log given by the failure

After I realized that I had to add a configuration section in angular.json under test architect node (for which was does not appear to be documented anywhere obvious), here is my config:

          "configurations": {
            "production": {
              "sourceMap": false,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }

When I try to add "aot": true, I get the following error:

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(aot).

Which defeats the purpose of trying to run unit tests in prod mode...

Desired functionality

Runs unit tests with a production version of a build (including AOT) and works

Mention any other details that might be useful

Late at night, I dream of being on a beach with the pleasing sound of lapping waves as I run ng test --prod

Activity

  1. filipesilva commented on Jul 20, 2018

    @filipesilva
    Contributor

    Heya, we don't support using AOT in unit tests. There's an open feature request at #6650 for it.

    I can say that last week I was actually on a beach and ran ng test a couple of times, never with --prod though. It was pleasant but have to say the glare on my (glossy) laptop monitor was annoying.

  2. boldwade commented on Jul 21, 2018

    @boldwade
    Author

    It is misleading though, as the wiki states it's possible:
    https://github.com/angular/angular-cli/wiki/test

  3. filipesilva commented on Jul 21, 2018

    @filipesilva
    Contributor

    That flag (--prod) does exist, but using a configuration, such as production, does not mean the same options are available as the browser build.

    For instance, you can have a production configuration for tests that includes code coverage, which isn't available on the browser build.

  4. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  5. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions