Skip to content

Commit 3775116

Browse files
committed
chore: remove support for browser field in config
1 parent 80b6905 commit 3775116

20 files changed

Lines changed: 16 additions & 178 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Fixes
66

7+
- `[jest-config, jest-resolve]` [**BREAKING**] Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943))
8+
79
### Chore & Maintenance
810

911
### Performance

TestUtils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
6767

6868
const DEFAULT_PROJECT_CONFIG: Config.ProjectConfig = {
6969
automock: false,
70-
browser: false,
7170
cache: false,
7271
cacheDirectory: '/test_cache_dir/',
7372
clearMocks: false,

docs/Configuration.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ Default: `0`
105105

106106
By default, Jest runs all tests and produces all errors into the console upon completion. The bail config option can be used here to have Jest stop running tests after `n` failures. Setting bail to `true` is the same as setting bail to `1`.
107107

108-
### `browser` [boolean]
109-
110-
Default: `false`
111-
112-
Respect Browserify's [`"browser"` field](https://github.com/substack/browserify-handbook#browser-field) in `package.json` when resolving modules. Some modules export different versions based on whether they are operating in Node or a browser.
113-
114108
### `cacheDirectory` [string]
115109

116110
Default: `"/tmp/<path>"`
@@ -689,7 +683,6 @@ This option allows the use of a custom resolver. This resolver must be a node mo
689683
```json
690684
{
691685
"basedir": string,
692-
"browser": bool,
693686
"defaultResolver": "function(request, options)",
694687
"extensions": [string],
695688
"moduleDirectory": [string],

e2e/__tests__/__snapshots__/showConfig.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ exports[`--showConfig outputs config info and exits 1`] = `
55
"configs": [
66
{
77
"automock": false,
8-
"browser": false,
98
"cache": false,
109
"cacheDirectory": "/tmp/jest",
1110
"clearMocks": false,

e2e/__tests__/resolveBrowserField.test.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

packages/jest-config/src/Defaults.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const NODE_MODULES_REGEXP = replacePathSepForRegex(NODE_MODULES);
1515
const defaultOptions: Config.DefaultOptions = {
1616
automock: false,
1717
bail: 0,
18-
browser: false,
1918
cache: true,
2019
cacheDirectory: getCacheDirectory(),
2120
changedFilesWithAncestor: false,

packages/jest-config/src/Deprecated.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ import prettyFormat = require('pretty-format');
1111
const format = (value: unknown) => prettyFormat(value, {min: true});
1212

1313
export default {
14+
browser: () => ` Option ${chalk.bold(
15+
'"browser"',
16+
)} has been deprecated. Please install \`browser-resolve\` and use the \`resolver\` option.
17+
18+
Jest now treats your current configuration as:
19+
{
20+
${chalk.bold('"resolve"')}: ${chalk.bold('"browser-resolve"')}
21+
}
22+
23+
Please update your configuration.
24+
`,
25+
1426
mapCoverage: () => ` Option ${chalk.bold(
1527
'"mapCoverage"',
1628
)} has been removed, as it's no longer necessary.

packages/jest-config/src/Descriptions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {Config} from '@jest/types';
1010
const descriptions: {[key in keyof Config.InitialOptions]: string} = {
1111
automock: 'All imported modules in your tests should be mocked automatically',
1212
bail: 'Stop running tests after `n` failures',
13-
browser: 'Respect "browser" field in package.json when resolving modules',
1413
cacheDirectory:
1514
'The directory where Jest should store its cached dependency information',
1615
clearMocks: 'Automatically clear mock calls and instances between every test',

packages/jest-config/src/ValidConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const NODE_MODULES_REGEXP = replacePathSepForRegex(NODE_MODULES);
1515
const initialOptions: Config.InitialOptions = {
1616
automock: false,
1717
bail: multipleValidOptions(false, 0),
18-
browser: false,
1918
cache: true,
2019
cacheDirectory: '/tmp/user/jest',
2120
changedFilesWithAncestor: false,

packages/jest-config/src/__tests__/normalize.test.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,6 @@ describe('automock', () => {
154154
});
155155
});
156156

157-
describe('browser', () => {
158-
it('falsy browser is not overwritten', () => {
159-
const {options} = normalize(
160-
{
161-
browser: true,
162-
rootDir: '/root/path/foo',
163-
},
164-
{},
165-
);
166-
167-
expect(options.browser).toBe(true);
168-
});
169-
});
170-
171157
describe('collectCoverageOnlyFrom', () => {
172158
it('normalizes all paths relative to rootDir', () => {
173159
const {options} = normalize(

0 commit comments

Comments
 (0)