Necesito ejecutar el siguiente código de configuración de la biblioteca en la inicialización de Jest:
import { enableMapSet, enableES5 } from "immer"; enableMapSet(); enableES5();Hago esto cuando inicializo mi aplicación CRA y mi libro de cuentos, pero ahora Jest también comenzó a fallar.
Intenté usar globalSetup así:
// 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(); };pero fue en vano, sigo recibiendo el 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 es la exportación predeterminada de "immer" , _noop es solo lodash noop.
¿Cuál es la forma correcta de ejecutar mi código de configuración? Odiaría tener que hacerlo en cada prueba individualmente.