Skip to content

cannot call mockImplementationOnce on empty function #58462

@bschelling

Description

@bschelling

Affected URL(s)

https://nodejs.org/en/learn/test-runner/mocking

Description of the problem

The example given "Modules + units" uses a call to mock.fn() without any parameters, causing " barMock.mockImplementationOnce" to fail later on.

I am not sure if the example is only for demonstration purposes but I tried to run it :)

const barMock = mock.fn();

Later on it calls:

 barMock.mockImplementationOnce(function bar_mock() {
      /* … */
    });

Since the barMock function did not receive a function parameter above, the call to barMock.mockImplementationOnce fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions