Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MessageEvent is not defined even when on Node version > 15 #12253

Closed
SamuelTrew opened this issue Jan 17, 2022 · 3 comments · Fixed by #12553
Closed

[Bug]: MessageEvent is not defined even when on Node version > 15 #12253

SamuelTrew opened this issue Jan 17, 2022 · 3 comments · Fixed by #12553

Comments

@SamuelTrew
Copy link

Version

27.4.7

Steps to reproduce

  1. Create project with jest with the test-environment as node
  2. Create a test file with:
const a = new MessageEvent('yes')
test('test', () => {
  return
})

to replicate a test.
3. run jest

Expected behavior

I expect the test to pass without error as Node now supports MessageEvent

Actual behavior

I get the following error

Screenshot 2022-01-17 at 13 29 56

Additional context

I'm using typescript but the test file still acts the same way in js or ts

Here is my jest config file:

import type { InitialOptionsTsJest } from 'ts-jest'
import { pathsToModuleNameMapper } from 'ts-jest'
import { compilerOptions } from './tsconfig.json'

const config: InitialOptionsTsJest = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  collectCoverage: true,
  coverageDirectory: 'coverage',
  slowTestThreshold: 2,
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src/js' }),
}

export default config

I've checked: jsdom/jsdom#3205 (comment) and #11528

But I don't think that the former applies here and the 2nd one seems like a non-fix as the node environment should fix it?

Environment

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  npmPackages:
    jest: ^27.4.7 => 27.4.7
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@SimenB
Copy link
Member

SimenB commented Apr 5, 2022

@github-actions
Copy link

github-actions bot commented May 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants