本文整理汇总了TypeScript中jest-util.clearLine函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clearLine函数的具体用法?TypeScript clearLine怎么用?TypeScript clearLine使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearLine函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
export async function run(maybeArgv?: Array<string>, project?: Config.Path) {
try {
const argv: Config.Argv = buildArgv(maybeArgv);
if (argv.init) {
await init();
return;
}
const projects = getProjectListFromCLIArgs(argv, project);
const {results, globalConfig} = await runCLI(argv, projects);
readResultsAndExit(results, globalConfig);
} catch (error) {
clearLine(process.stderr);
clearLine(process.stdout);
if (error.stack) {
console.error(chalk.red(error.stack));
} else {
console.error(chalk.red(error));
}
exit(1);
throw error;
}
}
示例2: onRunComplete
onRunComplete() {
this.forceFlushBufferedOutput();
this._status.runFinished();
process.stdout.write = this._out;
process.stderr.write = this._err;
clearLine(process.stderr);
}
示例3: clearLine
const showTestPathPatternError = (testPathPattern: string) => {
clearLine(process.stdout);
console.log(
chalk.red(
` Invalid testPattern ${testPathPattern} supplied. ` +
`Running all tests instead.`,
),
);
};
示例4: _addUntestedFiles
private async _addUntestedFiles(
globalConfig: Config.GlobalConfig,
contexts: Set<Context>,
): Promise<void> {
const files: Array<{config: Config.ProjectConfig; path: string}> = [];
contexts.forEach(context => {
const config = context.config;
if (
globalConfig.collectCoverageFrom &&
globalConfig.collectCoverageFrom.length
) {
context.hasteFS
.matchFilesWithGlob(globalConfig.collectCoverageFrom, config.rootDir)
.forEach(filePath =>
files.push({
config,
path: filePath,
}),
);
}
});
if (!files.length) {
return;
}
if (isInteractive) {
process.stderr.write(
RUNNING_TEST_COLOR('Running coverage on untested files...'),
);
}
let worker: CoverageWorker | Worker;
if (this._globalConfig.maxWorkers <= 1) {
worker = require('./coverage_worker');
} else {
worker = new Worker(require.resolve('./coverage_worker'), {
exposedMethods: ['worker'],
maxRetries: 2,
numWorkers: this._globalConfig.maxWorkers,
});
}
const instrumentation = files.map(async fileObj => {
const filename = fileObj.path;
const config = fileObj.config;
if (!this._coverageMap.data[filename] && 'worker' in worker) {
try {
const result = await worker.worker({
config,
globalConfig,
options: {
...this._options,
changedFiles:
this._options.changedFiles &&
Array.from(this._options.changedFiles),
},
path: filename,
});
if (result) {
this._coverageMap.addFileCoverage(result.coverage);
if (result.sourceMapPath) {
this._sourceMapStore.registerURL(filename, result.sourceMapPath);
}
}
} catch (error) {
console.error(
chalk.red(
[
`Failed to collect coverage from ${filename}`,
`ERROR: ${error.message}`,
`STACK: ${error.stack}`,
].join('\n'),
),
);
}
}
});
try {
await Promise.all(instrumentation);
} catch (err) {
// Do nothing; errors were reported earlier to the console.
}
if (isInteractive) {
clearLine(process.stderr);
}
if (worker && 'end' in worker && typeof worker.end === 'function') {
worker.end();
}
}