Skip to content

Commit d0675cc

Browse files
committed
Cleanup.
1 parent fb8e774 commit d0675cc

File tree

5 files changed

+56
-89
lines changed

5 files changed

+56
-89
lines changed

.github/renovate.json

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

packages/jest-haste-map/src/__tests__/worker.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ describe('worker', () => {
110110
await worker({
111111
computeDependencies: true,
112112
filePath: path.join('/project', 'fruits', 'Strawberry.js'),
113+
hasteImplModulePath: require.resolve('./haste_impl.js'),
113114
rootDir,
114115
}),
115116
).toEqual({

packages/jest-runtime/src/__mocks__/createRuntime.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ module.exports = async function createRuntime(filename, projectConfig) {
6060
projectConfig = makeProjectConfig({
6161
cacheDirectory: getCacheDirectory(),
6262
cwd,
63-
haste: {
64-
hasteImplModulePath: require.resolve(
65-
'../../../jest-haste-map/src/__tests__/haste_impl.js',
66-
),
67-
},
6863
id: `Runtime-${filename.replace(/\W/, '-')}.tests`,
6964
moduleDirectories: ['node_modules'],
7065
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
7166
rootDir,
7267
...projectConfig,
68+
haste: {
69+
...projectConfig?.haste,
70+
hasteImplModulePath: require.resolve(
71+
'../../../jest-haste-map/src/__tests__/haste_impl.js',
72+
),
73+
},
7374
moduleNameMapper,
7475
transform,
7576
});

packages/jest-runtime/src/__tests__/runtime_require_module.test.js

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -268,69 +268,52 @@ describe('Runtime requireModule', () => {
268268
});
269269

270270
it('resolves platform extensions based on the default platform', async () => {
271-
await Promise.all([
272-
createRuntime(__filename).then(runtime => {
273-
const exports = runtime.requireModule(
274-
runtime.__mockRootPath,
275-
'Platform',
276-
);
277-
278-
expect(exports.platform).toBe('default');
279-
}),
280-
createRuntime(__filename, {
281-
haste: {
282-
defaultPlatform: 'ios',
283-
platforms: ['ios', 'android'],
284-
},
285-
}).then(runtime => {
286-
const exports = runtime.requireModule(
287-
runtime.__mockRootPath,
288-
'Platform',
289-
);
290-
291-
expect(exports.platform).toBe('ios');
292-
}),
293-
createRuntime(__filename, {
294-
haste: {
295-
platforms: ['ios', 'android'],
296-
},
297-
}).then(runtime => {
298-
const exports = runtime.requireModule(
299-
runtime.__mockRootPath,
300-
'Platform',
301-
);
302-
303-
expect(exports.platform).toBe('default');
304-
}),
305-
createRuntime(__filename, {
306-
haste: {
307-
defaultPlatform: 'android',
308-
platforms: ['ios', 'android'],
309-
},
310-
}).then(runtime => {
311-
const exports = runtime.requireModule(
312-
runtime.__mockRootPath,
313-
'Platform',
314-
);
315-
316-
expect(exports.platform).toBe('android');
317-
}),
318-
createRuntime(__filename, {
319-
haste: {
320-
defaultPlatform: 'windows',
321-
platforms: ['ios', 'android', 'native', 'windows'],
322-
},
323-
}).then(runtime => {
324-
const exports = runtime.requireModule(
325-
runtime.__mockRootPath,
326-
'Platform',
327-
);
328-
329-
// We prefer `native` over the default module if the default one
330-
// cannot be found.
331-
expect(exports.platform).toBe('native');
332-
}),
333-
]);
271+
await createRuntime(__filename).then(runtime => {
272+
const exports = runtime.requireModule(runtime.__mockRootPath, 'Platform');
273+
274+
expect(exports.platform).toBe('default');
275+
});
276+
await createRuntime(__filename, {
277+
haste: {
278+
defaultPlatform: 'ios',
279+
platforms: ['ios', 'android'],
280+
},
281+
}).then(runtime => {
282+
const exports = runtime.requireModule(runtime.__mockRootPath, 'Platform');
283+
284+
expect(exports.platform).toBe('ios');
285+
});
286+
await createRuntime(__filename, {
287+
haste: {
288+
platforms: ['ios', 'android'],
289+
},
290+
}).then(runtime => {
291+
const exports = runtime.requireModule(runtime.__mockRootPath, 'Platform');
292+
293+
expect(exports.platform).toBe('default');
294+
});
295+
await createRuntime(__filename, {
296+
haste: {
297+
defaultPlatform: 'android',
298+
platforms: ['ios', 'android'],
299+
},
300+
}).then(runtime => {
301+
const exports = runtime.requireModule(runtime.__mockRootPath, 'Platform');
302+
303+
expect(exports.platform).toBe('android');
304+
});
305+
await createRuntime(__filename, {
306+
haste: {
307+
defaultPlatform: 'windows',
308+
platforms: ['ios', 'android', 'native', 'windows'],
309+
},
310+
}).then(runtime => {
311+
const exports = runtime.requireModule(runtime.__mockRootPath, 'Platform');
312+
313+
// We prefer `native` over the default module if the default one
314+
// cannot be found.
315+
expect(exports.platform).toBe('native');
316+
});
334317
});
335318

336319
it('finds modules encoded in UTF-8 *with BOM*', async () => {

packages/jest-transform/src/ScriptTransformer.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ const writeCacheFile = (cachePath: string, fileData: string) => {
939939
if (!(error instanceof Error)) {
940940
throw error;
941941
}
942-
if (cacheWriteErrorSafeToIgnore(error, cachePath)) {
942+
if (cacheWriteErrorSafeToIgnore(error)) {
943943
return;
944944
}
945945

@@ -957,10 +957,8 @@ const writeCacheFile = (cachePath: string, fileData: string) => {
957957
* If the target does not exist we do not know if it is because it is still
958958
* being written by another process or is being overwritten by another process.
959959
*/
960-
const cacheWriteErrorSafeToIgnore = (
961-
e: NodeJS.ErrnoException,
962-
cachePath: string,
963-
) => process.platform === 'win32' && e.code === 'EPERM';
960+
const cacheWriteErrorSafeToIgnore = (e: NodeJS.ErrnoException) =>
961+
process.platform === 'win32' && e.code === 'EPERM';
964962

965963
const readCacheFile = (cachePath: string): string | null => {
966964
if (!fs.existsSync(cachePath)) {

0 commit comments

Comments
 (0)