Repository: atom/atom
File: src/initialize-test-window.js (JavaScript)

Code before:
      if (packageMetadata.atomTranspilers) {
        CompileCache.addTranspilerConfigForPath(
          packageRoot,
          packageMetadata.name,
          packageMetadata,
          packageMetadata.atomTranspilers
        );
      }
    }

    document.title = 'Spec Suite';

    const clipboard = new Clipboard();
    TextEditor.setClipboard(clipboard);
    TextEditor.viewForItem = (item) => atom.views.getView(item);

    const testRunner = requireModule(testRunnerPath);
    const legacyTestRunner = require(legacyTestRunnerPath);
    const buildDefaultApplicationDelegate = () => new ApplicationDelegate();
    const buildAtomEnvironment = function (params) {
      params = { ...params };
      if (!params.hasOwnProperty('clipboard')) {
        params.clipboard = clipboard;
      }
      if (!params.hasOwnProperty('blobStore')) {
        params.blobStore = blobStore;
      }
      if (!params.hasOwnProperty('onlyLoadBaseStyleSheets')) {
        params.onlyLoadBaseStyleSheets = true;
      }
      const atomEnvironment = new AtomEnvironment(params);
      atomEnvironment.initialize(params);
      TextEditor.setScheduler(atomEnvironment.views);
      return atomEnvironment;
    };

    const statusCode = await testRunner({
      logFile,
      headless,
      testPaths,
      buildAtomEnvironment,
      buildDefaultApplicationDelegate,
      legacyTestRunner,
    });

    if (getWindowLoadSettings().headless) {
      exitWithStatusCode(statusCode);
    }
  } catch (error) {
    if (getWindowLoadSettings().headless) {
      console.error(error.stack || error);

Review comment (suggestion):
using `requireModule` instead of `require` here is the only change other than decaffeinating the file.

Code after:
    process.env.NODE_PATH = exportsPath; // Set NODE_PATH env variable since tasks may need it.

    updateProcessEnv(env);

    // Set up optional transpilation for packages under test if any
    const FindParentDir = require('find-parent-dir');
    const packageRoot = FindParentDir.sync(testPaths[0], 'package.json');
    if (packageRoot) {
      const packageMetadata = require(path.join(packageRoot, 'package.json'));
      if (packageMetadata.atomTranspilers) {
        CompileCache.addTranspilerConfigForPath(
          packageRoot,
          packageMetadata.name,
          packageMetadata,
          packageMetadata.atomTranspilers
        );
      }
    }

    document.title = 'Spec Suite';

    const clipboard = new Clipboard();
    TextEditor.setClipboard(clipboard);
    TextEditor.viewForItem = item => atom.views.getView(item);

    const testRunner = requireModule(testRunnerPath);
    const legacyTestRunner = require(legacyTestRunnerPath);
    const buildDefaultApplicationDelegate = () => new ApplicationDelegate();
    const buildAtomEnvironment = function(params) {
      params = cloneObject(params);
      if (!params.hasOwnProperty('clipboard')) {
        params.clipboard = clipboard;
      }
      if (!params.hasOwnProperty('blobStore')) {
        params.blobStore = blobStore;
      }
      if (!params.hasOwnProperty('onlyLoadBaseStyleSheets')) {
        params.onlyLoadBaseStyleSheets = true;
      }
      const atomEnvironment = new AtomEnvironment(params);
      atomEnvironment.initialize(params);
      TextEditor.setScheduler(atomEnvironment.views);
      return atomEnvironment;
    };

    const statusCode = await testRunner({
      logFile,
      headless,
      testPaths,
      buildAtomEnvironment,
      buildDefaultApplicationDelegate,