diff --git a/e2e/resolve-conditions/__tests__/custom-env-override-conditions.mjs b/e2e/resolve-conditions/__tests__/custom-env-override-conditions.mjs new file mode 100644 index 000000000000..059a92c45767 --- /dev/null +++ b/e2e/resolve-conditions/__tests__/custom-env-override-conditions.mjs @@ -0,0 +1,15 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @jest-environment /custom-env.js + * @jest-environment-options {"customExportConditions": ["react-native"]} + */ + +import {fn} from 'fake-dual-dep'; + +test('returns correct message', () => { + expect(fn()).toBe('hello from react native'); +}); diff --git a/e2e/resolve-conditions/__tests__/deno.test.mjs b/e2e/resolve-conditions/__tests__/custom-env.test.mjs similarity index 87% rename from e2e/resolve-conditions/__tests__/deno.test.mjs rename to e2e/resolve-conditions/__tests__/custom-env.test.mjs index 75fac0e3ea33..9f48b4071007 100644 --- a/e2e/resolve-conditions/__tests__/deno.test.mjs +++ b/e2e/resolve-conditions/__tests__/custom-env.test.mjs @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @jest-environment /deno-env.js + * @jest-environment /custom-env.js */ import {fn} from 'fake-dual-dep'; diff --git a/e2e/resolve-conditions/deno-env.js b/e2e/resolve-conditions/custom-env.js similarity index 71% rename from e2e/resolve-conditions/deno-env.js rename to e2e/resolve-conditions/custom-env.js index 137dbf487eb6..74f83a770ea0 100644 --- a/e2e/resolve-conditions/deno-env.js +++ b/e2e/resolve-conditions/custom-env.js @@ -9,8 +9,6 @@ const NodeEnv = require('jest-environment-node').TestEnvironment; -module.exports = class DenoEnvWithConditions extends NodeEnv { - exportConditions() { - return ['deno']; - } +module.exports = class CustomEnvWithConditions extends NodeEnv { + customExportConditions = ['deno']; }; diff --git a/e2e/resolve-conditions/node_modules/fake-dual-dep/package.json b/e2e/resolve-conditions/node_modules/fake-dual-dep/package.json index f868e6f55426..d574ed50d85b 100644 --- a/e2e/resolve-conditions/node_modules/fake-dual-dep/package.json +++ b/e2e/resolve-conditions/node_modules/fake-dual-dep/package.json @@ -6,6 +6,7 @@ "deno": "./deno.mjs", "node": "./node.mjs", "browser": "./browser.mjs", + "react-native": "./react-native.js", "special": "./special.mjs" } } diff --git a/e2e/resolve-conditions/node_modules/fake-dual-dep/react-native.js b/e2e/resolve-conditions/node_modules/fake-dual-dep/react-native.js new file mode 100644 index 000000000000..1b3f487fce4c --- /dev/null +++ b/e2e/resolve-conditions/node_modules/fake-dual-dep/react-native.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +module.exports = function fn() { + return 'hello from react-native'; +}