<commit_before>var jsdom = require("jsdom");

// Helper function for loading react; see comment when we load react
var withNavigator = function(lambda) {
    var oldNavigator = global.navigator;
    global.navigator = { userAgent: "Node" };
    var result = lambda();
    global.navigator = oldNavigator;
    return result;
};

// Enable jsx files (with es6)
require('node-jsx').install({
  extension: '.jsx',
  harmony: true
});

// Fake being a web browser
global.document = jsdom.jsdom();
global.window = document.parentWindow;

var _ = require("../lib/underscore.js");
global._ = global.window._ = _;

// Create a function to copy globals from `window` to `global`
var jsdomWindowProps = _.clone(global.window);
var updateGlobals = function() {
    // Update only things we add to window, but not properties created by
    // jsdom, since making those globals can confuse jsdom.
    // We can't use a plain _.each(global.window) here because window has
    // a .length property (set to 0), which makes _ think it's array-like
    _.each(_.keys(global.window), function(key) {
        if (!_.has(jsdomWindowProps, key)) {
            global[key] = global.window[key];
        }
    });
};

// Third-party global dependencies
global.React = window.React = withNavigator(function() {
    // react-with-addons requires global.navigator to be defined,
    // but some other deps (including requirejs) require it to be
    // undefined to detect that we are running in Node.
    // We therefore define it only while loading React.
    return require("../lib/react-with-addons.js");
});
require("../lib/jquery.js");
markedReact = require("../lib/marked.js");
updateGlobals();

// First-party global dependencies
require("./i18n-shim.js");
updateGlobals();
require("./ke-deps-shim.js");
updateGlobals();
global.katex = window.katex = require("../lib/katex/katex.js");
global.KAS = {};
require("../ke/local-only/kas.js");
window.KAS = global.KAS; // don't ask--check out the KAS source.

// Hacky assertion functions for jest compatibility
// TODO(jack): Change tests to not use these, or choose jest vs mocha
var assert = require("assert");
global.expect = function(thing) {
    return {
        toEqual: function(other) {
            assert(_.isEqual(thing, other), "" + thing + " != " + other);
        },
        toBe: function(other) {<commit_msg>Make tests pass again<commit_after>var jsdom = require("jsdom");

// Helper function for loading react; see comment when we load react
var withNavigator = function(lambda) {
    var oldNavigator = global.navigator;
    global.navigator = { userAgent: "Node" };
    var result = lambda();
    global.navigator = oldNavigator;
    return result;
};

// Enable jsx files (with es6)
require('node-jsx').install({
  extension: '.jsx',
  harmony: true
});

// Fake being a web browser
global.document = jsdom.jsdom();
global.window = document.parentWindow;

var _ = require("../lib/underscore.js");
global._ = global.window._ = _;

// Create a function to copy globals from `window` to `global`
var jsdomWindowProps = _.clone(global.window);
var updateGlobals = function() {
    // Update only things we add to window, but not properties created by
    // jsdom, since making those globals can confuse jsdom.
    // We can't use a plain _.each(global.window) here because window has
    // a .length property (set to 0), which makes _ think it's array-like
    _.each(_.keys(global.window), function(key) {
        if (!_.has(jsdomWindowProps, key)) {
            global[key] = global.window[key];
        }
    });
};

// Third-party global dependencies
global.React = window.React = withNavigator(function() {
    // react-with-addons requires global.navigator to be defined,
    // but some other deps (including requirejs) require it to be
    // undefined to detect that we are running in Node.
    // We therefore define it only while loading React.
    return require("../lib/react-with-addons.js");
});
require("../lib/jquery.js");
window.markedReact = require("../lib/marked.js");
window.RCSS = require("../lib/rcss.js");
updateGlobals();

// First-party global dependencies
require("./i18n-shim.js");
updateGlobals();
require("./ke-deps-shim.js");
updateGlobals();
global.katex = window.katex = require("../lib/katex/katex.js");
global.KAS = {};
require("../ke/local-only/kas.js");
window.KAS = global.KAS; // don't ask--check out the KAS source.

// Hacky assertion functions for jest compatibility
// TODO(jack): Change tests to not use these, or choose jest vs mocha
var assert = require("assert");
global.expect = function(thing) {
    return {
        toEqual: function(other) {
            assert(_.isEqual(thing, other), "" + thing + " != " + other);
        },
        toBe: function(other) {
{'fraction_non_alphanumeric': 0.1454124579124579, 'fraction_numerical': 0.0016835016835016834, 'mean_word_length': 3.281981981981982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4290586', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1435, 'n_words': 433}