Skip to content

Unit testing documentation not working because of a breaking change in jest-mock-extended v.2.0.0 #2109

Closed

Description

@fbennets

Bug description

The documentation for unit testing is currently not working due to typescript errors.

Version 2.00 of jest-mock-extended, which is used in the documentation, contains some breaking changes, the changelog states: Potential backwards compatibility issues for use of mock() where deepMock() may be required. This may result in TS errors.

A quick fix is to just install version 1.0.18 using:

npm install [email protected] --save-dev

It would be a good idea to update the documentation here.

How to reproduce

  1. Follow the documentation for unit testing.
  2. Typescript throws an error when trying to call prismaMock.user.create.mockResolvedValue(user) as mockResolvedValue is not available.

Expected behavior

No response

Prisma information

Irrelevant

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: v14.17.3

Prisma Version

prisma               : 2.27.0
@prisma/client       : 2.27.0

Activity

  1. transferred this issue fromprisma/ormon Aug 8, 2021
  2. molebox commented on Aug 9, 2021

    @molebox
    Contributor

    Hey @fbennets thanks for this. Im currently talking with another user and came to the same conclusion. Will update the docs today. 🙌

  3. fbennets commented on Aug 9, 2021

    @fbennets
    Author

    Thanks! But I noticed that the changed docs still don't work for me when using jest-mock-extended 2.0.2-beta2.

    import { DeepMockProxy } from "jest-mock-extended/lib/Mock"; gives me the following error: Cannot find module 'jest-mock-extended/lib/Mock' or its corresponding type declarations.

    It works when importing from the sub-folder /mjs/:
    import { DeepMockProxy } from "jest-mock-extended/lib/mjs/Mock";

    But maybe it's just some misconfiguration on my side.

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