Skip to content

Latest commit

 

History

History
32 lines (19 loc) · 618 Bytes

context.md

File metadata and controls

32 lines (19 loc) · 618 Bytes

.context([key]) => Any

Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.

Arguments

  1. key (String [optional]): If provided, the return value will be the this.context[key] of the root component instance.

Example

const wrapper = mount(
  <MyComponent />,
  { context: { foo: 10 } }
);

expect(wrapper.context().foo).to.equal(10);
expect(wrapper.context('foo')).to.equal(10);

Related Methods