const createHasteContext = ( config, _ref) => {let hasteFS = _ref.hasteFS,moduleMap = _ref.moduleMap;return ( { hasteFS, moduleMap, resolver: Runtime.createResolver(config, moduleMap) });};
export default ( config: ProjectConfig, {hasteFS, moduleMap}: HasteMap, ): Context => ({ config, hasteFS, moduleMap, resolver: Runtime.createResolver(config, moduleMap), });
const getResolver = (config, rawModuleMap) => { // In watch mode, the raw module map with all haste modules is passed from // the test runner to the watch command. This is because jest-haste-map's // watch mode does not persist the haste map on disk after every file change. // To make this fast and consistent, we pass it from the TestRunner. if (rawModuleMap) { return Runtime.createResolver(config, new HasteMap.ModuleMap(rawModuleMap)); } else { const name = config.name; if (!resolvers[name]) { resolvers[name] = Runtime.createResolver( config, Runtime.createHasteMap(config).readModuleMap(), ); } return resolvers[name]; } };
module.exports = (data, callback) => { try { const name = data.config.name; if (!resolvers[name]) { resolvers[name] = Runtime.createResolver( data.config, Runtime.createHasteMap(data.config).read());} new Test(data.path, data.config, resolvers[name]). run(). then( result => callback(null, result), error => callback(formatError(error)));} catch (error) { callback(formatError(error));}};