Skip to content

Commit

Permalink
chore(jest-haste-map): Remove legacy isRegExpSupported (#12676)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhogan committed Apr 16, 2022
1 parent e746660 commit 06040d3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -105,6 +105,7 @@
- `[@jest/core]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329))
- `[jest-environment-jsdom]` [**BREAKING**] Migrate to ESM ([#12340](https://github.com/facebook/jest/pull/12340))
- `[jest-environment-node]` [**BREAKING**] Migrate to ESM ([#12340](https://github.com/facebook/jest/pull/12340))
- `[jest-haste-map]` Remove legacy `isRegExpSupported` ([#12676](https://github.com/facebook/jest/pull/12676))
- `[@jest/fake-timers]` Update `@sinonjs/fake_timers` to v9 ([#12357](https://github.com/facebook/jest/pull/12357))
- `[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))
- `[jest-phabricator]` [**BREAKING**] Migrate to ESM ([#12341](https://github.com/facebook/jest/pull/12341))
Expand Down
Expand Up @@ -6,9 +6,6 @@
*/

import {extractor} from '../dependencyExtractor';
import isRegExpSupported from '../isRegExpSupported';

const COMMENT_NO_NEG_LB = isRegExpSupported('(?<!\\.\\s*)') ? '' : '//';

describe('dependencyExtractor', () => {
it('should not extract dependencies inside comments', () => {
Expand Down Expand Up @@ -65,8 +62,8 @@ describe('dependencyExtractor', () => {
}, depDefault from 'dep4';
// Bad
${COMMENT_NO_NEG_LB} foo . import ('inv1');
${COMMENT_NO_NEG_LB} foo . export ('inv2');
foo . import ('inv1');
foo . export ('inv2');
`;
expect(extractor.extract(code)).toEqual(
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
Expand Down Expand Up @@ -114,8 +111,8 @@ describe('dependencyExtractor', () => {
}, depDefault from 'dep4';
// Bad
${COMMENT_NO_NEG_LB} foo . export ('inv1');
${COMMENT_NO_NEG_LB} foo . export ('inv2');
foo . export ('inv1');
foo . export ('inv2');
`;
expect(extractor.extract(code)).toEqual(
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
Expand All @@ -137,8 +134,8 @@ describe('dependencyExtractor', () => {
}, depDefault from 'dep4';
// Bad
${COMMENT_NO_NEG_LB} foo . export ('inv1');
${COMMENT_NO_NEG_LB} foo . export ('inv2');
foo . export ('inv1');
foo . export ('inv2');
`;
expect(extractor.extract(code)).toEqual(
new Set(['dep1', 'dep2', 'dep3', 'dep4']),
Expand All @@ -164,7 +161,7 @@ describe('dependencyExtractor', () => {
if (await import(\`dep3\`)) {}
// Bad
${COMMENT_NO_NEG_LB} await foo . import('inv1')
await foo . import('inv1')
await ximport('inv2');
importx('inv3');
import('inv4', 'inv5');
Expand All @@ -182,7 +179,7 @@ describe('dependencyExtractor', () => {
if (require(\`dep3\`).cond) {}
// Bad
${COMMENT_NO_NEG_LB} foo . require('inv1')
foo . require('inv1')
xrequire('inv2');
requirex('inv3');
require('inv4', 'inv5');
Expand All @@ -202,7 +199,7 @@ describe('dependencyExtractor', () => {
.requireActual('dep4');
// Bad
${COMMENT_NO_NEG_LB} foo . jest.requireActual('inv1')
foo . jest.requireActual('inv1')
xjest.requireActual('inv2');
jest.requireActualx('inv3');
jest.requireActual('inv4', 'inv5');
Expand All @@ -224,7 +221,7 @@ describe('dependencyExtractor', () => {
.requireMock('dep4');
// Bad
${COMMENT_NO_NEG_LB} foo . jest.requireMock('inv1')
foo . jest.requireMock('inv1')
xjest.requireMock('inv2');
jest.requireMockx('inv3');
jest.requireMock('inv4', 'inv5');
Expand All @@ -246,7 +243,7 @@ describe('dependencyExtractor', () => {
.requireMock('dep4');
// Bad
${COMMENT_NO_NEG_LB} foo . jest.genMockFromModule('inv1')
foo . jest.genMockFromModule('inv1')
xjest.genMockFromModule('inv2');
jest.genMockFromModulex('inv3');
jest.genMockFromModule('inv4', 'inv5');
Expand All @@ -268,7 +265,7 @@ describe('dependencyExtractor', () => {
.requireMock('dep4');
// Bad
${COMMENT_NO_NEG_LB} foo . jest.createMockFromModule('inv1')
foo . jest.createMockFromModule('inv1')
xjest.createMockFromModule('inv2');
jest.createMockFromModulex('inv3');
jest.createMockFromModule('inv4', 'inv5');
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions packages/jest-haste-map/src/lib/dependencyExtractor.ts
Expand Up @@ -6,12 +6,8 @@
*/

import type {DependencyExtractor} from '../types';
import isRegExpSupported from './isRegExpSupported';

// Negative look behind is only supported in Node 9+
const NOT_A_DOT = isRegExpSupported('(?<!\\.\\s*)')
? '(?<!\\.\\s*)'
: '(?:^|[^.]\\s*)';
const NOT_A_DOT = '(?<!\\.\\s*)';
const CAPTURE_STRING_LITERAL = (pos: number) =>
`([\`'"])([^'"\`]*?)(?:\\${pos})`;
const WORD_SEPARATOR = '\\b';
Expand Down
16 changes: 0 additions & 16 deletions packages/jest-haste-map/src/lib/isRegExpSupported.ts

This file was deleted.

0 comments on commit 06040d3

Please sign in to comment.