Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
How to globally enable immer mapSet for all Jest tests?

I need to run the following library setup code on Jest initialization:

import { enableMapSet, enableES5 } from "immer";

enableMapSet();
enableES5();

I do this when initializing my CRA app and storybook, but now Jest started crashing too.

I tried using globalSetup like this:

// jest.config.js
module.exports = {
  testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(test).[jt]s?(x)"],
  globalSetup: "./jest.setup.js",
};
// jest.setup.js
import { enableMapSet, enableES5 } from "immer";

// <- also tried calling the setup fns on this very line, with no luck

export default () => {
  enableMapSet();
  enableES5();
};

but to no avail, I'm still getting the error:

src/xxx/myTest.test.js
  ● Test suite failed to run

    [Immer] The plugin for 'MapSet' has not been loaded into Immer. To enable the plugin, import and call `enableMapSet()` when initializing your application.

       8 | 
    >  9 | export const immerFreeze = <T extends any>(x: T): T => produce(x, _noop);
         |                                                        ^

produce is default export from "immer", _noop is just lodash noop.

What is the correct way to run my setup code? I'd hate do have to do it in each test individually.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda