{"size": 3159, "ext": "js", "max_stars_repo_path": "node_modules/eth-saddle/dist/test_env.js", "max_stars_repo_name": "aj07/ampt", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/eth-saddle/dist/test_env.js", "max_issues_repo_name": "aj07/ampt", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/eth-saddle/dist/test_env.js", "max_forks_repo_name": "aj07/ampt", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 43.875, "max_line_length": 131, "alphanum_fraction": 0.6264640709}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jest_environment_node_1 = __importDefault(require("jest-environment-node"));
const saddle_1 = require("./saddle");
const coverage_1 = require("./coverage");
const path = __importStar(require("path"));
class CustomEnvironment extends jest_environment_node_1.default {
    constructor(config, context) {
        super(config);
        this.testName = path.relative(process.cwd(), context.testPath).split(path.sep).join('-').replace('.', '_');
        this.coverage = config.testEnvironmentOptions['coverage'] === 'true';
    }
    async setup() {
        let start = new Date();
        let saddle = await saddle_1.getSaddle('test', this.coverage);
        this.global['saddle'] = saddle;
        this.global['coverage'] = this.coverage;
        this.global['web3'] = saddle.web3;
        this.global['call'] = saddle.call;
        this.global['send'] = saddle.send;
        this.global['deploy'] = saddle.deploy;
        this.global['account'] = saddle.account;
        this.global['accounts'] = saddle.accounts;
        console.log(`Setup in ${new Date().getTime() - start.getTime()} ms`);
        await super.setup();
    }
    async teardown() {
        let start = new Date();
        if (this.coverage) {
            await this.global['saddle'].network_config.providerEngine.stop();
            let coverage = this.global['saddle'].network_config.cov._coverageCollector._collector.getFinalCoverage();
            await coverage_1.writeCoverage(this.global['saddle'].saddle_config, this.testName, coverage);
        }
        delete this.global['saddle'];
        delete this.global['coverage'];
        delete this.global['web3'];
        delete this.global['call'];
        delete this.global['send'];
        delete this.global['deploy'];
        delete this.global['account'];
        delete this.global['accounts'];
        console.log(`Teardown in ${new Date().getTime() - start.getTime()} ms`);
        await super.teardown();
    }
    runScript(script) {
        return super.runScript(script);
    }
}
exports.default = CustomEnvironment;
//# sourceMappingURL=test_env.js.map