<commit_before>var ssr = require("../lib/");
var helpers = require("./helpers");
var assert = require("assert");
var iterate = require("leakage").iterate;
var path = require("path");
var through = require("through2");

describe("Memory leaks", function(){
	this.timeout(10000);

	before(function(){
		this.oldXHR = global.XMLHttpRequest;
		global.XMLHttpRequest = helpers.mockXHR(
			'[ { "a": "a" }, { "b": "b" } ]');

		var render = ssr({
			config: "file:" + path.join(__dirname, "tests", "package.json!npm"),
			main: "async/index.stache!done-autorender"
		});

		this.render = function(pth){
			return new Promise(function(resolve, reject){
				var stream = through(function(buffer){
					resolve(buffer);
				});
				stream.on("error", reject);
				render(pth).pipe(stream);
			});
		};
	});

	after(function(){
		global.XMLHttpRequest = this.oldXHR;
	});

	it("do not happen", function(done){
		iterate(10, () => {
			return this.render("/");
		})
		.then(() => {
			done();
		})
		.catch(done);
	});
});
<commit_msg>Increase the leak test timeout for CI<commit_after>/* jshint esversion: 6 */
var ssr = require("../lib/");
var helpers = require("./helpers");
var iterate = require("leakage").iterate;
var path = require("path");
var through = require("through2");

describe("Memory leaks", function(){
	this.timeout(30000);

	before(function(){
		this.oldXHR = global.XMLHttpRequest;
		global.XMLHttpRequest = helpers.mockXHR(
			'[ { "a": "a" }, { "b": "b" } ]');

		var render = ssr({
			config: "file:" + path.join(__dirname, "tests", "package.json!npm"),
			main: "async/index.stache!done-autorender"
		});

		this.render = function(pth){
			return new Promise(function(resolve, reject){
				var stream = through(function(buffer){
					resolve(buffer);
				});
				stream.on("error", reject);
				render(pth).pipe(stream);
			});
		};
	});

	after(function(){
		global.XMLHttpRequest = this.oldXHR;
	});

	it("do not happen", function(done){
		iterate(10, () => {
			return this.render("/");
		})
		.then(() => {
			done();
		})
		.catch(done);
	});
});

{'fraction_non_alphanumeric': 0.21055179090029041, 'fraction_numerical': 0.008228460793804453, 'mean_word_length': 3.8981042654028437, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, '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': '2801859', 'n_tokens_mistral': 823, 'n_tokens_neox': 706, 'n_words': 141}