Skip to content

Flaky Cannot assign to read only property 'owner' of object '#<Context>' #561

Open

Description

@rreckonerr

Cannot assign to read only property 'owner' of object '#<Context>'

I'm upgrading test suit from ember-cli-mocha to ember-mocha 0.15.1 and get randomly failing tests all over again and those tests look fine when I'm running them separately. Is there a way to find out what's causing this error?

Activity

  1. rreckonerr commented on May 14, 2020

    @rreckonerr
    Author

    Mentioned error appears because of some tests being started before the previous one is finished, which results in tests getting wrong originalContext and not being able to clean it up properly. Is my assumption correct? Any ideas how can I debug this further?

      beforeEach(function () {
        originalContext = _assign({}, this);
        console.group(
          `${originalContext.test.parent.title} => ${originalContext.currentTest.title}`
        );
        return setupContext(this, options)
          .then(() => setupPauseTest(this))
          .then(() => chainHooks(beforeEachHooks, this));
      });
    
      afterEach(function () {
        return chainHooks(afterEachHooks, this)
          .then(() => teardownContext(this))
          .then(() => {
            // delete any extraneous properties
            for (let key in this) {
              if (!(key in originalContext)) {
                console.log("key to delete :>> ", key);
                delete this[key];
              }
            }
    
            // copy over the original values
            _assign(this, originalContext);
          })
          .catch((error) => {
            console.log("this :>> ", this);
            console.log("originalContext :>> ", originalContext);
            console.error(error);
          })
          .finally(() => {
            console.groupEnd();
          });
      });

    image

    Example in the screenshot is failing randomly.

  2. notchris commented on Jun 3, 2021

    @notchris

    Can confirm this issue occurs

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