UNPKG

@japa/snapshot

Version:

Snapshot testing plugin for Japa

29 lines (27 loc) 687 B
import { PluginContext, isModuleInstalled } from "./chunk-5UVLWMSF.js"; // index.ts import { Test } from "@japa/runner/core"; function snapshot(options = {}) { if (isModuleInstalled("@japa/assert")) { import("./assert-OUA23GGN.js"); } if (isModuleInstalled("@japa/expect")) { import("./expect-FVVWBBD6.js"); } const snapshotPlugin = function({ config, cliArgs }) { PluginContext.init(options, cliArgs); Test.executing((test) => { PluginContext.setCurrentTestContext(test.context); }); config.teardown.push(async () => { await PluginContext.snapshotManager.saveSnapshots(); }); }; return snapshotPlugin; } export { snapshot };