Karma: Improve Error Message Handling

Created on 17 May 2017  路  5Comments  路  Source: karma-runner/karma

Expected behaviour

When the execution of some test fails, the error message should be fully transferred to the console log for debugging purposes.

Actual behaviour

Currently, when an error occurs e.g. inside a promise inside a zone.js, the error message is only partially transferred to the console. This is due to the JSON.stringify() representation of the message not containing all parts of the error message.

E.g. the console log might only show

{
    "originalErr": {},
    "__zone_symbol__currentTask": {
      "type": "microTask",
      "state": "notScheduled",
      "source": "Promise.then",
      "zone": "<root>",
      "cancelFn": null,
      "runCount": 0
    }
  }

Executed 0 of 0 ERROR 

which tells you nothing about the actual problem, which can be found with message.toString() in the this.error() method in https://github.com/karma-runner/karma/blob/master/client/karma.js#L116
In our case this resulted in

Error: (SystemJS) Object prototype may only be an Object or null: undefined
TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf 

Environment Details

  • Karma version 1.6.0

All 5 comments

I'm also getting error in a angular 2 project

21 06 2017 13:55:24.334:WARN [web-server]: 404: /base/traceur.js
Chrome 58.0.3029 (Mac OS X 10.12.4) ERROR
  {
    "originalErr": {
      "__zone_symbol__currentTask": {
        "type": "microTask",
        "state": "notScheduled",
        "source": "Promise.then",
        "zone": "<root>",
        "cancelFn": null,
        "runCount": 0
      }
    },
    "__zone_symbol__currentTask": {
      "type": "microTask",
      "state": "notScheduled",
      "source": "Promise.then",
      "zone": "<root>",
      "cancelFn": null,
      "runCount": 0
    }
  }
Chrome 58.0.3029 (Mac OS X 10.12.4): Executed 0 of 0 ERROR (0.424 secs / 0 secs)

How can I fix this? using "karma": "^1.7.0".

28 06 2017 16:03:36.328:INFO [Chrome 58.0.3029 (Mac OS X 10.12.4)]: Connected on socket JinIe5EH6rRYz9frAAAA with id 18860069
28 06 2017 16:03:37.625:WARN [web-server]: 404: /base/fs-extra.js
28 06 2017 16:03:37.627:WARN [web-server]: 404: /base/glob.js
Chrome 58.0.3029 (Mac OS X 10.12.4) ERROR
  {
    "originalErr": {
      "__zone_symbol__currentTask": {
        "type": "microTask",
        "state": "notScheduled",
        "source": "Promise.then",
        "zone": "<root>",
        "cancelFn": null,
        "runCount": 0
      }
    },
    "__zone_symbol__currentTask": {
      "type": "microTask",
      "state": "notScheduled",
      "source": "Promise.then",
      "zone": "<root>",
      "cancelFn": null,
      "runCount": 0
    }
  }
Chrome 58.0.3029 (Mac OS X 10.12.4): Executed 0 of 0 ERROR (0.513 secs / 0 secs)

How to fix this error? Any help would be appreciated?

@kushwahashiv try to apply the changes I suggested in https://github.com/karma-runner/karma/pull/2712/files in order to get more information about the error.
From the 404 messages you can already see that some files could not be loaded.

Thanks @macjohnny! You saved me some precious time 馃憤

@wesleycho please have a look at https://github.com/karma-runner/karma/pull/2712 again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joerideg picture joerideg  路  5Comments

charpour picture charpour  路  3Comments

ebacka picture ebacka  路  3Comments

TKTheTechie picture TKTheTechie  路  4Comments

schippie picture schippie  路  5Comments