Skip to content

[Bug]: breaking behavior for TypeScript globals compared to the DefinitelyTyped counterpart #12853

@noomorph

Description

@noomorph

Version

28.1.0

Steps to reproduce

  1. Clone my repo from: https://github.com/noomorph/tsc-jest-28-issue
  2. Follow the README there.

Expected behavior

I expect that importing @jest/globals would indeed add common things like describe, it, test, beforeEach, etc. to the global scope, so I don't have to import them every time explicitly:

import { describe, it, expect } from '@jest/globals';

Actual behavior

I'm seeing TSC errors like these on an attempt to compile my test suites:

globals.test.ts(1,1): error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.
globals.test.ts(2,3): error TS2304: Cannot find name 'beforeEach'.
globals.test.ts(6,3): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

Additional context

No response

Environment

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0

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