Skip to content

userContext not shared from beforeEach #3673

@valthon

Description

@valthon

I believe this is a bug

Current Behavior

Regression in 20.0.1. this is a fresh / empty object for every test. Values assigned to this in beforeEach are not accessible from tests.

I believe commit a9a322f introduced the regression.

Repro

https://repl.it/IUml/0

describe('userContext', function() {
  beforeEach(function() {
    this.foo = 'bar';
  });
  test('is accessible', function() {
    expect(this.foo).toEqual('bar');
  });
});

Expected Behavior

values assigned to this in a beforeEach function should be accessible to test functions. (Similar to how Jasmine works). This change is breaking the tests I recently migrated from Jasmine.

Versions, etc

Broken for Jest 20.0.4. Working for my yarn.lock that uses Jest 20.0.0.
Using yarn 0.24.6 on OSX Sierra.

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