UNPKG

@titan-suite/cli

Version:

The complete smart contract development tool

37 lines (36 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const fs = require("fs"); const mocha = require("mocha"); class Test extends command_1.Command { run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { args } = this.parse(Test); let _mocha = new mocha(); if (args.file) { _mocha.addFile(`${process.cwd()}/${args.file}`); } else { fs.readdirSync(`${process.cwd()}/test`).filter(function (file) { return file.substr(-3) === '.js'; }).forEach(function (file) { _mocha.addFile(`${process.cwd()}/test/${file}`); }); } _mocha.run(function (failures) { process.exitCode = failures ? -1 : 0; // exit with non-zero status if there were failures }); }); } } Test.description = 'Run unit tests that interact Solidity smart contract'; Test.examples = [ '$ titan test <path/to/test/testExample.js>', ]; Test.flags = { help: command_1.flags.help({ char: 'h' }), }; Test.args = [{ name: 'file' }]; exports.default = Test;