How to use the jest-runtime.createHasteMap function in jest-runtime

To help you get started, we’ve selected a few jest-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook-atom / jest-electron-runner / packages / electron / src / utils / resolver.js View on Github external
// 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 (serializableModuleMap) {
    const moduleMap = serializableModuleMap
      ? HasteMap.ModuleMap.fromJSON(serializableModuleMap)
      : null;
    return wrapResolver(
      Runtime.createResolver(config, new HasteMap.ModuleMap(moduleMap)),
    );
  } else {
    const name = config.name;
    if (!resolvers[name]) {
      resolvers[name] = wrapResolver(
        Runtime.createResolver(
          config,
          Runtime.createHasteMap(config).readModuleMap(),
        ),
      );
    }
    return resolvers[name];
  }
};
github facebookarchive / atom-ide-ui / modules / jest-atom-runner / src / atomTestRunner.js View on Github external
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 wrapResolver(
      Runtime.createResolver(config, new HasteMap.ModuleMap(rawModuleMap)),
    );
  } else {
    const name = config.name;
    if (!resolvers[name]) {
      resolvers[name] = wrapResolver(
        Runtime.createResolver(
          config,
          Runtime.createHasteMap(config).readModuleMap(),
        ),
      );
    }
    return resolvers[name];
  }
};
github danger / danger-js / source / runner / DangerfileRunner.ts View on Github external
const environment: Environment = new NodeEnvironment(config)

  const runnerGlobal = environment.global
  const context = dangerfileContext

  // Adds things like fail, warn ... to global
  for (const prop in context) {
    if (context.hasOwnProperty(prop)) {
      const anyContext: any = context
      runnerGlobal[prop] = anyContext[prop]
    }
  }

  // Setup a runtime environment
  const hasteConfig = { automock: false, maxWorkers: 1, resetCache: false }
  const hasteMap = await Runtime.createHasteMap(config, hasteConfig).build()
  const resolver = Runtime.createResolver(config, hasteMap.moduleMap)
  const runtime = new Runtime(config, environment, resolver)

  return {
    context,
    environment,
    runtime
  }
}
github d4rkr00t / jest-electron-runner / runner.html View on Github external
ipcRenderer.on('run', (evt, { file, config, globalConfig }) => {
      Runtime.createHasteMap(config, { maxWorkers: os.cpus().length - 1, watchman: globalConfig.watchman })
        .build()
        .then(hasteMap => {
          const resolver = Runtime.createResolver(config, hasteMap.moduleMap);
          runTest(file, globalConfig, config, resolver)
            .then(results => {
              ipcRenderer.send('test-results', results);
              window.close();
            })
            .catch(e => {
              ipcRenderer.send('error', (e instanceof Error) ? e.message : e.toString());
              window.close();
            });
        });
    });
github d4rkr00t / jest-electron-runner / packages / jest-electron-runner / electron-runner.js View on Github external
ipcRenderer.on("run", (evt, { file, config, globalConfig }) => {
  Runtime.createHasteMap(config, {
    maxWorkers: os.cpus().length - 1,
    watchman: globalConfig.watchman
  })
    .build()
    .then(hasteMap => {
      const resolver = Runtime.createResolver(config, hasteMap.moduleMap);
      runTest(file, globalConfig, config, resolver)
        .then(results => {
          ipcRenderer.send("test-results", results);
          window.close();
        })
        .catch(e => {
          ipcRenderer.send(
            "error",
            e instanceof Error ? e.message : e.toString()
          );

jest-runtime

MIT
Latest version published 8 months ago

Package Health Score

87 / 100
Full package analysis

Similar packages