karma-runner / karma-runner/karma-jasmine

Opening Context.html window raises an error for parentWindow.karma object "Cannot read property 'info' of undefined"

Open
#331 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
537
Forks
162
PR merge metrics
No merged PRs in 30d

Description

if I open CONTEXT page with jasmine test result while tests are running locally, It will always end up with errors:
TypeError: Cannot read properties of undefined (reading 'info')

the issue is happening inside of context.js script due to karma is undefined for parentWindow object

ContextKarma.getDirectCallParentKarmaMethod = function (parentWindow) {
  return function directCallParentKarmaMethod (method, args) {
    // If the method doesn't exist, then error out
    if (!parentWindow.karma[method]) {
      parentWindow.karma.error('Expected Karma method "' + method + '" to exist but it doesn\'t')
      return
    }

    // Otherwise, run our method
    parentWindow.karma[method].apply(parentWindow.karma, args)
  }
}

Steps to reproduce:

  1. Generate a new project from scratch by angular cli: ng n <project_name>.
  2. Run unit tests: ng test.
  3. open http://localhost:9876/context.html while executing tests locally
  4. expect result: context page shows a tests result without errors, actual result: context page shows errors.
  5. The issue is similar to https://github.com/karma-runner/karma-jasmine/issues/147

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in context.js at ContextKarma.getDirectCallParentKarmaMethod and reproduce the problem by opening context.html at localhost:9876 while ng test is running. Trace how the parent window is obtained when parentWindow.karma is unavailable. Done means the context page displays the test result without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.