Skip to content

Object with a property called 'version' causes problems in testing #2540

Closed

Description

@LMFinney

Please provide us with the following information:

OS?

Windows 7

Versions.

angular-cli: 1.0.0-beta.16
node: 6.6.0
os: win32 x64

Repro steps.

  • Create a new CLI project from scratch.
  • Add the following to app.component.ts:
  constructor() {
    console.log('Handle1', {id: 123, version: 4});
    console.log('Handle2', {id: 123, verion: 4});
  }
  • run ng test
  • You'll see that the second console logging statement prints, but the first doesn't.

The log given by the failure.

No logging - that's the problem.

Mention any other details that might be useful.

The original manifestation of this problem was that I put an object that looks like one of the objects above in an Immutable.js List, but then almost all of the methods on the List failed (i.e. console.log(list.toArray()) never printed). Eventually, I was able to reproduce it in the simpler form that seemingly just the word "version" as a property name caused problems.

This has happened on two machines, one using the chrome launcher and one using the firefox launcher. I don't see the problem by trying to log a similar object literal in the node REPL, the Chrome console, or the Firefox console.

I don't have the problem running the application in the browser - just in the karma test.

Activity

  1. RoopeHakulinen commented on Oct 7, 2016

    @RoopeHakulinen
    Contributor

    I don't think this is an issue with Angular CLI. Angular CLI will simply trigger the Karma and this error is even reproducible without usage of ng test using plain Karma. Please report this to the Karma if there isn't an issue about it yet.

  2. LMFinney commented on Oct 7, 2016

    @LMFinney
    Author

    I don't think @RoopeHakulinen is correct. I get different results running ng test vs karma start:

    C:\sandbox\cli>karma start
    07 10 2016 12:15:27.873:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
    07 10 2016 12:15:27.883:INFO [launcher]: Starting browser Chrome
    07 10 2016 12:15:29.236:INFO [Chrome 53.0.2785 (Windows 7 0.0.0)]: Connected on socket /#dKPeJs-yj1QnM1t8AAAA with id 97416767
    LOG: 'Handle1', Object{id: 123, version: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
    LOG: 'Handle1', Object{id: 123, version: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 1 of 3 SUCCESS (0 secs / 0.087 secs)
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 1 of 3 SUCCESS (0 secs / 0.087 secs)
    LOG: 'Handle1', Object{id: 123, version: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 2 of 3 SUCCESS (0 secs / 0.127 secs)
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 2 of 3 SUCCESS (0 secs / 0.127 secs)
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 3 of 3 SUCCESS (0.186 secs / 0.17 secs)
    
    C:\sandbox\cli>ng test
    07 10 2016 12:15:45.681:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
    07 10 2016 12:15:45.686:INFO [launcher]: Starting browser Chrome
    07 10 2016 12:15:47.128:INFO [Chrome 53.0.2785 (Windows 7 0.0.0)]: Connected on socket /#99qD4KtjnIPACRNaAAAA with id 11008890
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 1 of 3 SUCCESS (0 secs / 0.092 secs)
    LOG: 'Handle2', Object{id: 123, verion: 4}
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 2 of 3 SUCCESS (0 secs / 0.136 secs)
    Chrome 53.0.2785 (Windows 7 0.0.0): Executed 3 of 3 SUCCESS (0.195 secs / 0.178 secs)
    

    Notice that Handle2 is displayed in both runs, but Handle1 does not appear for ng test. I made no changes to code or configuration between these runs.

    It looks to me like karma has no problem with this, but ng test does.

  3. RoopeHakulinen commented on Oct 8, 2016

    @RoopeHakulinen
    Contributor

    @LMFinney Seems that it was my mistake. I ran the tests again, and now it produces the same result for me. So you are right and this seems like a legit problem. I'll take a look at what happens on the execution.

  4. LMFinney commented on Oct 8, 2016

    @LMFinney
    Author

    Thanks!

    On Oct 8, 2016 5:25 AM, "Roope Hakulinen" notifications@github.com wrote:

    @LMFinney https://github.com/LMFinney Seems that it was my mistake. I
    ran the tests again, and now it produces the same result for me. So you are
    right and this seems like a legit problem. I'll take a look at what happens
    on the execution.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    #2540 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AGX8Y_Pz5RGEB-4KEPp1HsDDwhIjbsypks5qx2-TgaJpZM4KPe12
    .

  5. filipesilva commented on Oct 10, 2016

    @filipesilva
    Contributor

    Whoa that's weird. I just tried it with the console logs outside of the constructor, just in src/app/app.component.ts, and could repro on ng test (but not on ng serve).

  6. filipesilva commented on Oct 10, 2016

    @filipesilva
    Contributor

    Even weirder... those console.log appear on the karma debugger:
    image

    Edit: also on the plain karma window, for that matter:
    image

  7. added 2 commits that reference this issue on Oct 10, 2016
    edc14dd
    9e15ec7
  8. added 4 commits that reference this issue on Oct 15, 2016
    0127fcc
    dfbd726
    9696259
    4608445
  9. added a commit that references this issue on Oct 19, 2016
    ea33d10
  10. added a commit that references this issue on Oct 21, 2016
    48d58a0
  11. added a commit that references this issue on Nov 3, 2016
    7f0a3ce
  12. angular-automatic-lock-bot commented on Sep 6, 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.

  13. locked and limited conversation to collaborators on Sep 6, 2019
  14. added a commit that references this issue on May 29, 2026
    1a95192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions