<commit_before>const { readFileSync } = require('fs');
const { sync: globbySync } = require('globby');
const { join } = require('path');
const ts = require('typescript');

const { emit } = require('..');

function getSourceFile(source) {
  const options = Object.assign(
    {},
    ts.getDefaultCompilerOptions(),
    {
      experimentalDecorators: true,
      jsx: ts.JsxEmit.Preserve,
      noEmit: true,
      noResolve: true,
      preserveConstEnums: true,
      removeComments: false,
      target: ts.ScriptTarget.Latest
    }
  );
  const host = Object.assign(
    {},
    ts.createCompilerHost(options, true),
    {
      getSourceFile(fileName, languageVersion) {
        return ts.createSourceFile(fileName, source, languageVersion, true);
      }
    }
  );
  const program = ts.createProgram(['source.tsx'], options, host);
  return program.getSourceFile('source.tsx');
}

module.exports = {
  runner: function(part) {
    const paths = globbySync([join(__dirname, `typescript/tests/cases/compiler/${part}*.ts`)]);
    if (paths.length > 0) {
      paths.forEach(path => {
        test(path, () => {
          const source = readFileSync(path).toString();
          expect(emit(getSourceFile(source))).toBe(source);
        });
      });
    } else {
      test.skip(`Runner for ${part} as zero tests`, () => {});
    }
  }
};<commit_msg>test: toggle js vs jsx in test harness<commit_after>const { readFileSync } = require('fs');
const { sync: globbySync } = require('globby');
const { join } = require('path');
const ts = require('typescript');

const { emit } = require('..');

function getSourceFile(path, source) {
  const options = Object.assign(
    {},
    ts.getDefaultCompilerOptions(),
    {
      experimentalDecorators: true,
      jsx: ts.JsxEmit.Preserve,
      noEmit: true,
      noResolve: true,
      preserveConstEnums: true,
      removeComments: false,
      target: ts.ScriptTarget.Latest
    }
  );
  const host = Object.assign(
    {},
    ts.createCompilerHost(options, true),
    {
      getSourceFile(fileName, languageVersion) {
        return ts.createSourceFile(fileName, source, languageVersion, true);
      }
    }
  );
  const program = ts.createProgram([path], options, host);
  return program.getSourceFile(path);
}

module.exports = {
  runner: function(part) {
    const paths = globbySync([join(__dirname, `typescript/tests/cases/compiler/${part}*.ts`)]);
    if (paths.length > 0) {
      paths.forEach(path => {
        test(path, () => {
          const source = readFileSync(path).toString();
          expect(emit(getSourceFile(path, source))).toBe(source);
        });
      });
    } else {
      test.skip(`Runner for ${part} as zero tests`, () => {});
    }
  }
};
{'fraction_non_alphanumeric': 0.15584891822515584, 'fraction_numerical': 0.0007334066740007334, 'mean_word_length': 3.011764705882353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1036131', 'n_tokens_mistral': 833, 'n_tokens_neox': 839, 'n_words': 165}