{"id":"9941f5d2146fca6d","repo":"jestjs/jest","slug":"custom-export-conditions-specified-but-they-are-no","errorCode":null,"errorMessage":"Custom export conditions specified but they are not an array of strings","messagePattern":"Custom export conditions specified but they are not an array of strings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-environment-jsdom-abstract/src/index.ts","lineNumber":150,"sourceCode":"    };\n    global.removeEventListener = function (\n      ...args: Parameters<typeof originalRemoveListener>\n    ) {\n      if (args[0] === 'error') {\n        userErrorListenerCount--;\n      }\n      return originalRemoveListener.apply(this, args);\n    };\n\n    if ('customExportConditions' in projectConfig.testEnvironmentOptions) {\n      const {customExportConditions} = projectConfig.testEnvironmentOptions;\n      if (\n        Array.isArray(customExportConditions) &&\n        customExportConditions.every(isString)\n      ) {\n        this._configuredExportConditions = customExportConditions;\n      } else {\n        throw new Error(\n          'Custom export conditions specified but they are not an array of strings',\n        );\n      }\n    }\n\n    this.moduleMocker = new ModuleMocker(global);\n\n    this.fakeTimers = new LegacyFakeTimers({\n      config: projectConfig,\n      global,\n      moduleMocker: this.moduleMocker,\n      timerConfig: {\n        idToRef: (id: number) => id,\n        refToId: (ref: number) => ref,\n      },\n    });\n\n    this.fakeTimersModern = new ModernFakeTimers({","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-environment-jsdom-abstract/src/index.ts#L132-L168","documentation":"BaseJSDOMEnvironment reads `testEnvironmentOptions.customExportConditions` and requires it to be an Array where every element is a string; otherwise it throws at index.ts:150. These conditions drive package.json `exports` resolution (default `['browser']`), so a malformed value would silently break module resolution.","triggerScenarios":"Setting `customExportConditions: 'browser'` (string instead of array), `customExportConditions: [42]`, or `customExportConditions: {import: 'browser'}` via `@jest-environment-options` docblock or jest.config.","commonSituations":"Copy-paste from a doc snippet that quotes a single condition; mixing up `testEnvironmentOptions` with `testEnvironment`; passing a TS enum or object expecting it to coerce.","solutions":["Set the value to an array of strings, e.g. `customExportConditions: ['browser']`.","Remove the key entirely to accept the environment default (`['browser']`).","If overriding per-file via docblock, JSON-encode the array: `{\"customExportConditions\": [\"browser\"]}`."],"exampleFix":"// before\n/**\n * @jest-environment jsdom\n * @jest-environment-options {\"customExportConditions\": \"browser\"}\n */\n\n// after\n/**\n * @jest-environment jsdom\n * @jest-environment-options {\"customExportConditions\": [\"browser\"]}\n */","handlingStrategy":"validation","validationCode":"const opts = config.testEnvironmentOptions?.customExportConditions;\nif (opts != null && (!Array.isArray(opts) || !opts.every(v => typeof v === 'string'))) {\n  throw new Error('customExportConditions must be string[]');\n}","typeGuard":"const isExportConditions = (v: unknown): v is string[] => Array.isArray(v) && v.every(x => typeof x === 'string');","tryCatchPattern":null,"preventionTips":["Always pass an array of strings.","Validate config with a zod/joi schema before booting Jest.","Avoid single-string shorthand even if it looks plausible."],"tags":["jest-environment","jsdom","config","exports"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}