@mypaas/hcm-cli
Version:
Vant Cli 是一个 Vue 组件库构建工具,通过 Vant Cli 可以快速搭建一套功能完备的 Vue 组件库。
43 lines (42 loc) • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.test = void 0;
const jest_1 = require("jest");
const common_1 = require("../common");
const gen_package_entry_1 = require("../compiler/gen-package-entry");
const constant_1 = require("../common/constant");
function test(command) {
common_1.setNodeEnv('test');
gen_package_entry_1.genPackageEntry({
outputPath: constant_1.TEST_PACKAGE_ENTRY_FILE,
});
const config = {
rootDir: constant_1.ROOT,
watch: command.watch,
config: constant_1.JEST_CONFIG_FILE,
clearCache: command.clearCache,
changedSince: command.changedSince,
logHeapUsage: command.logHeapUsage,
runInBand: command.runInBand,
debug: command.debug,
};
if (command.only) {
const jestConfig = require(constant_1.JEST_CONFIG_FILE);
jestConfig.testMatch = [`**/${command.only}/**/?(*.)+(spec|test).[jt]s?(x)`];
jestConfig.collectCoverageFrom = [`src/${command.only}/**/*.{js,jsx,ts,tsx,vue}`, '!**/demo/**'];
config.config = JSON.stringify(jestConfig);
}
jest_1.runCLI(config, [constant_1.ROOT])
.then(response => {
if (!response.results.success && !command.watch) {
process.exit(1);
}
})
.catch(err => {
console.log(err);
if (!command.watch) {
process.exit(1);
}
});
}
exports.test = test;