Skip to content

Commit 06040d3

Browse files
authored
chore(jest-haste-map): Remove legacy isRegExpSupported (#12676)
1 parent e746660 commit 06040d3

File tree

5 files changed

+14
-54
lines changed

5 files changed

+14
-54
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
- `[@jest/core]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329))
106106
- `[jest-environment-jsdom]` [**BREAKING**] Migrate to ESM ([#12340](https://github.com/facebook/jest/pull/12340))
107107
- `[jest-environment-node]` [**BREAKING**] Migrate to ESM ([#12340](https://github.com/facebook/jest/pull/12340))
108+
- `[jest-haste-map]` Remove legacy `isRegExpSupported` ([#12676](https://github.com/facebook/jest/pull/12676))
108109
- `[@jest/fake-timers]` Update `@sinonjs/fake_timers` to v9 ([#12357](https://github.com/facebook/jest/pull/12357))
109110
- `[jest-jasmine2, jest-runtime]` [**BREAKING**] Use `Symbol` to pass `jest.setTimeout` value instead of `jasmine` specific logic ([#12124](https://github.com/facebook/jest/pull/12124))
110111
- `[jest-phabricator]` [**BREAKING**] Migrate to ESM ([#12341](https://github.com/facebook/jest/pull/12341))

packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
*/
77

88
import {extractor} from '../dependencyExtractor';
9-
import isRegExpSupported from '../isRegExpSupported';
10-
11-
const COMMENT_NO_NEG_LB = isRegExpSupported('(?<!\\.\\s*)') ? '' : '//';
129

1310
describe('dependencyExtractor', () => {
1411
it('should not extract dependencies inside comments', () => {
@@ -65,8 +62,8 @@ describe('dependencyExtractor', () => {
6562
}, depDefault from 'dep4';
6663
6764
// Bad
68-
${COMMENT_NO_NEG_LB} foo . import ('inv1');
69-
${COMMENT_NO_NEG_LB} foo . export ('inv2');
65+
foo . import ('inv1');
66+
foo . export ('inv2');
7067
`;
7168
expect(extractor.extract(code)).toEqual(
7269
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
@@ -114,8 +111,8 @@ describe('dependencyExtractor', () => {
114111
}, depDefault from 'dep4';
115112
116113
// Bad
117-
${COMMENT_NO_NEG_LB} foo . export ('inv1');
118-
${COMMENT_NO_NEG_LB} foo . export ('inv2');
114+
foo . export ('inv1');
115+
foo . export ('inv2');
119116
`;
120117
expect(extractor.extract(code)).toEqual(
121118
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
@@ -137,8 +134,8 @@ describe('dependencyExtractor', () => {
137134
}, depDefault from 'dep4';
138135
139136
// Bad
140-
${COMMENT_NO_NEG_LB} foo . export ('inv1');
141-
${COMMENT_NO_NEG_LB} foo . export ('inv2');
137+
foo . export ('inv1');
138+
foo . export ('inv2');
142139
`;
143140
expect(extractor.extract(code)).toEqual(
144141
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
@@ -164,7 +161,7 @@ describe('dependencyExtractor', () => {
164161
if (await import(\`dep3\`)) {}
165162
166163
// Bad
167-
${COMMENT_NO_NEG_LB} await foo . import('inv1')
164+
await foo . import('inv1')
168165
await ximport('inv2');
169166
importx('inv3');
170167
import('inv4', 'inv5');
@@ -182,7 +179,7 @@ describe('dependencyExtractor', () => {
182179
if (require(\`dep3\`).cond) {}
183180
184181
// Bad
185-
${COMMENT_NO_NEG_LB} foo . require('inv1')
182+
foo . require('inv1')
186183
xrequire('inv2');
187184
requirex('inv3');
188185
require('inv4', 'inv5');
@@ -202,7 +199,7 @@ describe('dependencyExtractor', () => {
202199
.requireActual('dep4');
203200
204201
// Bad
205-
${COMMENT_NO_NEG_LB} foo . jest.requireActual('inv1')
202+
foo . jest.requireActual('inv1')
206203
xjest.requireActual('inv2');
207204
jest.requireActualx('inv3');
208205
jest.requireActual('inv4', 'inv5');
@@ -224,7 +221,7 @@ describe('dependencyExtractor', () => {
224221
.requireMock('dep4');
225222
226223
// Bad
227-
${COMMENT_NO_NEG_LB} foo . jest.requireMock('inv1')
224+
foo . jest.requireMock('inv1')
228225
xjest.requireMock('inv2');
229226
jest.requireMockx('inv3');
230227
jest.requireMock('inv4', 'inv5');
@@ -246,7 +243,7 @@ describe('dependencyExtractor', () => {
246243
.requireMock('dep4');
247244
248245
// Bad
249-
${COMMENT_NO_NEG_LB} foo . jest.genMockFromModule('inv1')
246+
foo . jest.genMockFromModule('inv1')
250247
xjest.genMockFromModule('inv2');
251248
jest.genMockFromModulex('inv3');
252249
jest.genMockFromModule('inv4', 'inv5');
@@ -268,7 +265,7 @@ describe('dependencyExtractor', () => {
268265
.requireMock('dep4');
269266
270267
// Bad
271-
${COMMENT_NO_NEG_LB} foo . jest.createMockFromModule('inv1')
268+
foo . jest.createMockFromModule('inv1')
272269
xjest.createMockFromModule('inv2');
273270
jest.createMockFromModulex('inv3');
274271
jest.createMockFromModule('inv4', 'inv5');

packages/jest-haste-map/src/lib/__tests__/isRegExpSupported.test.js

-18
This file was deleted.

packages/jest-haste-map/src/lib/dependencyExtractor.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
*/
77

88
import type {DependencyExtractor} from '../types';
9-
import isRegExpSupported from './isRegExpSupported';
109

11-
// Negative look behind is only supported in Node 9+
12-
const NOT_A_DOT = isRegExpSupported('(?<!\\.\\s*)')
13-
? '(?<!\\.\\s*)'
14-
: '(?:^|[^.]\\s*)';
10+
const NOT_A_DOT = '(?<!\\.\\s*)';
1511
const CAPTURE_STRING_LITERAL = (pos: number) =>
1612
`([\`'"])([^'"\`]*?)(?:\\${pos})`;
1713
const WORD_SEPARATOR = '\\b';

packages/jest-haste-map/src/lib/isRegExpSupported.ts

-16
This file was deleted.

0 commit comments

Comments
 (0)