Skip to content

Commit

Permalink
chore: remove export = from jest-haste-map
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 9, 2022
1 parent f5aeae7 commit d7f628c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
22 changes: 11 additions & 11 deletions packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jest.mock('jest-worker', () => ({
}));

jest.mock('../crawlers/node');
jest.mock('../crawlers/watchman', () =>
jest.fn(options => {
jest.mock('../crawlers/watchman', () => ({
watchmanCrawl: jest.fn(options => {
const path = require('path');

const {data, ignore, rootDir, roots, computeSha1} = options;
Expand Down Expand Up @@ -66,7 +66,7 @@ jest.mock('../crawlers/watchman', () =>
removedFiles,
});
}),
);
}));

const mockWatcherConstructor = jest.fn(root => {
const EventEmitter = require('events').EventEmitter;
Expand Down Expand Up @@ -555,7 +555,7 @@ describe('HasteMap', () => {

describe('builds a haste map on a fresh cache with SHA-1s', () => {
it.each([false, true])('uses watchman: %s', async useWatchman => {
const node = require('../crawlers/node');
const node = require('../crawlers/node').nodeCrawl;

node.mockImplementation(options => {
const {data} = options;
Expand Down Expand Up @@ -1195,7 +1195,7 @@ describe('HasteMap', () => {
});

it('ignores files that do not exist', async () => {
const watchman = require('../crawlers/watchman');
const watchman = require('../crawlers/watchman').watchmanCrawl;
const mockImpl = watchman.getMockImplementation();
// Wrap the watchman mock and add an invalid file to the file list.
watchman.mockImplementation(options =>
Expand Down Expand Up @@ -1293,8 +1293,8 @@ describe('HasteMap', () => {
});

it('tries to crawl using node as a fallback', async () => {
const watchman = require('../crawlers/watchman');
const node = require('../crawlers/node');
const watchman = require('../crawlers/watchman').watchmanCrawl;
const node = require('../crawlers/node').nodeCrawl;

watchman.mockImplementation(() => {
throw new Error('watchman error');
Expand Down Expand Up @@ -1331,8 +1331,8 @@ describe('HasteMap', () => {
});

it('tries to crawl using node as a fallback when promise fails once', async () => {
const watchman = require('../crawlers/watchman');
const node = require('../crawlers/node');
const watchman = require('../crawlers/watchman').watchmanCrawl;
const node = require('../crawlers/node').nodeCrawl;

watchman.mockImplementation(() =>
Promise.reject(new Error('watchman error')),
Expand Down Expand Up @@ -1369,8 +1369,8 @@ describe('HasteMap', () => {

it('stops crawling when both crawlers fail', async () => {
expect.assertions(1);
const watchman = require('../crawlers/watchman');
const node = require('../crawlers/node');
const watchman = require('../crawlers/watchman').watchmanCrawl;
const node = require('../crawlers/node').nodeCrawl;

watchman.mockImplementation(() =>
Promise.reject(new Error('watchman error')),
Expand Down
18 changes: 9 additions & 9 deletions packages/jest-haste-map/src/crawlers/__tests__/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('node crawler', () => {

it('crawls for files based on patterns', async () => {
childProcess = require('child_process');
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

mockResponse = [
'/project/fruits/pear.js',
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('node crawler', () => {
});

it('updates only changed files', async () => {
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

// In this test sample, strawberry is changed and tomato is unchanged
const tomato = ['', 33, 42, 1, '', null];
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('node crawler', () => {
});

it('returns removed files', async () => {
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

// In this test sample, previouslyExisted was present before and will not be
// when crawling this directory.
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('node crawler', () => {
mockSpawnExit = 1;
childProcess = require('child_process');

nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

const {hasteMap, removedFiles} = await nodeCrawl({
data: {
Expand Down Expand Up @@ -285,7 +285,7 @@ describe('node crawler', () => {
childProcess.spawn.mockImplementationOnce(() => {
throw new Error();
});
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

const {hasteMap, removedFiles} = await nodeCrawl({
data: {
Expand All @@ -308,7 +308,7 @@ describe('node crawler', () => {

it('uses node fs APIs if "forceNodeFilesystemAPI" is set to true, regardless of platform', async () => {
childProcess = require('child_process');
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

const files = new Map();
const {hasteMap, removedFiles} = await nodeCrawl({
Expand All @@ -331,7 +331,7 @@ describe('node crawler', () => {
});

it('completes with empty roots', async () => {
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

const files = new Map();
const {hasteMap, removedFiles} = await nodeCrawl({
Expand All @@ -348,7 +348,7 @@ describe('node crawler', () => {
});

it('completes with fs.readdir throwing an error', async () => {
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;

const files = new Map();
const {hasteMap, removedFiles} = await nodeCrawl({
Expand All @@ -365,7 +365,7 @@ describe('node crawler', () => {
});

it('avoids calling lstat for directories and symlinks', async () => {
nodeCrawl = require('../node');
nodeCrawl = require('../node').nodeCrawl;
const fs = require('graceful-fs');

const files = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const createMap = obj => new Map(Object.keys(obj).map(key => [key, obj[key]]));

describe('watchman watch', () => {
beforeEach(() => {
watchmanCrawl = require('../watchman');
watchmanCrawl = require('../watchman').watchmanCrawl;

watchman = require('fb-watchman');

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-haste-map/src/crawlers/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function findNative(
});
}

export = async function nodeCrawl(options: CrawlerOptions): Promise<{
export async function nodeCrawl(options: CrawlerOptions): Promise<{
removedFiles: FileData;
hasteMap: InternalHasteMap;
}> {
Expand Down Expand Up @@ -237,4 +237,4 @@ export = async function nodeCrawl(options: CrawlerOptions): Promise<{
find(roots, extensions, ignore, enableSymlinks, callback);
}
});
};
}
4 changes: 2 additions & 2 deletions packages/jest-haste-map/src/crawlers/watchman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function capabilityCheck(
});
}

export = async function watchmanCrawl(options: CrawlerOptions): Promise<{
export async function watchmanCrawl(options: CrawlerOptions): Promise<{
changedFiles?: FileData;
removedFiles: FileData;
hasteMap: InternalHasteMap;
Expand Down Expand Up @@ -353,4 +353,4 @@ export = async function watchmanCrawl(options: CrawlerOptions): Promise<{
hasteMap: data,
removedFiles,
};
};
}
4 changes: 2 additions & 2 deletions packages/jest-haste-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {Worker} from 'jest-worker';
import HasteFS from './HasteFS';
import HasteModuleMap from './ModuleMap';
import H from './constants';
import nodeCrawl = require('./crawlers/node');
import watchmanCrawl = require('./crawlers/watchman');
import {nodeCrawl} from './crawlers/node';
import {watchmanCrawl} from './crawlers/watchman';
import getMockName from './getMockName';
import * as fastPath from './lib/fast_path';
import getPlatformExtension from './lib/getPlatformExtension';
Expand Down

0 comments on commit d7f628c

Please sign in to comment.