Skip to content

jest.spyOn() provide a way to inspect the return value #3821

Closed
@evan-scott-zocdoc

Description

@evan-scott-zocdoc

Do you want to request a feature or report a bug?
feature

What is the current behavior?
when something is spied upon, you can see invocation arguments, but not what the return value was

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?
something like:

jest.spyOn(window, 'getComputedStyle');

// something

expect(window.getComputedStyle).toHaveReturned(
  expect.objectContaining({
    overflow: 'hidden',
  });
);

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
jest 19
node 8
npm 5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions