pact-toolbox
Version:
A tool to help you build, test and deploy your Pact smart contracts
49 lines (47 loc) • 1.18 kB
JavaScript
import { defineCommand } from "citty";
import { resolveConfig } from "@pact-toolbox/config";
import { runReplTests } from "@pact-toolbox/test";
import { startVitest } from "vitest/node";
//#region src/commands/test.ts
async function runVitest({ mode = "test", watch = false, filters = [] } = {}) {
const vitest = await startVitest(mode, filters, {
watch,
run: !watch,
testTimeout: 1e4
});
if (!watch) await vitest?.exit();
}
const testCommand = defineCommand({
meta: {
name: "test",
description: "Run tests using the configured test runner and network"
},
args: {
watch: {
type: "boolean",
name: "watch",
alias: "w",
description: "Watch for changes and re-run tests",
required: false,
default: false
},
replOnly: {
type: "boolean",
name: "repl-only",
alias: "r",
description: "Run REPL tests only",
required: false,
default: false
}
},
run: async ({ args }) => {
const { replOnly, watch } = args;
const config = await resolveConfig();
await runReplTests(config);
if (replOnly === true) return;
await runVitest({ watch });
}
});
//#endregion
export { testCommand };
//# sourceMappingURL=test-Dn4wI283.js.map