Skip to content

Documentation: MockFunctionMetadata no longer part of jest-mock #15309

Open
@frankvollebregt

Description

@frankvollebregt

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In the example over in the documentation, the following import is used:

import { MockFunctionMetadata } from 'jest-mock';

But since version 30 of jest-mock, MockFunctionMetadata was removed (see https://jestjs.io/docs/upgrading-to-jest30#removed-mock-function-types). Though an alternative is not specifically provided there, I successfully fixed my tests by using

import { MockMetadata } from 'jest-mock';

Minimum reproduction code

https://gist.github.com/frankvollebregt/a1c7b14480fb0d7c6252d08f6b291c4a

Steps to reproduce

  1. Use the auto mocking code from the Nest docs
  2. Upgrade jest-mock to version 30
  3. MockFunctionMetadata can no longer be resolved

Expected behavior

The documentation page should probably be updated to instead use the MockMetadata type, which fixes the syntax and tests again, as far as I can tell

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

jest-mock

NestJS version

11.1.3

Packages versions

[System Information]
OS Version     : Windows10.0.26100
NodeJS Version : v22.13.0
NPM Version    : 10.8.3

[Nest CLI]
Nest CLI Version : 11.0.7

[Nest Platform Information
platform-express version : 11.1.3
schematics version       : 11.0.5
swagger version          : 11.2.0
testing version          : 11.1.3
common version           : 11.1.3
config version           : 4.0.2
axios version            : 4.0.0
core version             : 11.1.3
jwt version              : 11.0.0
cli version              : 11.0.7

Node.js version

22.13.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions