UNPKG

unmock-jest

Version:

Jest reporter for [Unmock](https://unmock.io).

34 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chalk_1 = require("chalk"); const unmock_node_1 = require("unmock-node"); const options_1 = require("./options"); const write_report_1 = require("./write-report"); exports.write = (jestData, options) => { const snapshots = unmock_node_1.utils.snapshotter .getOrUpdateSnapshotter() .readSnapshots(); return write_report_1.default({ jestData, snapshots }, options); }; const formatLogString = (writtenFilePath) => { return ` ${chalk_1.default.bold.magentaBright("unmock")}: Wrote report to ${chalk_1.default.magenta(writtenFilePath)}`; }; class UnmockJestReporter { constructor(globalConfig, reporterOptions) { this.globalConfig = globalConfig; this.reporterOptions = reporterOptions; this.options = options_1.resolveOptions(reporterOptions); this.rootDir = globalConfig.rootDir; } onRunStart() { unmock_node_1.utils.snapshotter.getOrUpdateSnapshotter().deleteSnapshots(); } onRunComplete(_, results) { const writtenFilePath = exports.write({ aggregatedResult: results }, this.options); console.log(formatLogString(writtenFilePath)); } } exports.default = UnmockJestReporter; //# sourceMappingURL=index.js.map