本文整理匯總了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();
}
}