create-tezos-smart-contract
Version:
Node.js toolset to write, test and deploy Tezos smart contracts
37 lines (36 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.test = exports.addTestCommand = void 0;
const console_1 = require("../../console");
const bundle_1 = require("../../modules/bundle");
const config_1 = require("../../modules/config");
const jest_1 = require("../../modules/jest");
const addTestCommand = (program, debugHook) => {
program
.command('test')
.description('Perform unit tests on smart contracts with Jest.')
.option('-n, --network <network>', `Choose to run test either in ${config_1.ToolchainNetworks.SANDBOX} or ${config_1.ToolchainNetworks.TESTNET} networks`)
.option('--old-build', 'Use the latest contract build found instead of stopping/rebuilding')
.action((options) => {
(0, exports.test)(program, options);
})
.hook('preAction', debugHook);
};
exports.addTestCommand = addTestCommand;
// Lauch Jest to run unit tests
const test = async (program, options) => {
(0, console_1.em)(`Perform unit tests...\n`);
// Read configfile
const contractsBundle = new bundle_1.ContractsBundle((0, console_1.getCWD)());
// Read the config so contracts folder settings will be there later
await contractsBundle.readConfigFile();
// Prepare options
const defaultOptions = {
network: config_1.ToolchainNetworks.SANDBOX,
};
// Build final options
const testOptions = Object.assign({}, defaultOptions, options);
(0, console_1.log)(`Working on "${testOptions.network}" network`);
await (0, jest_1.testWithJest)(contractsBundle, testOptions);
};
exports.test = test;