本文整理汇总了TypeScript中mocha.run函数的典型用法代码示例。如果您正苦于以下问题:TypeScript run函数的具体用法?TypeScript run怎么用?TypeScript run使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Mocha
const runMocha = (baseDir: string, mochaOptions, proc: NodeJS.Process) => {
const mocha = new Mocha(mochaOptions);
const testFiles = getTestFiles(baseDir);
_.forEach(testFiles, (testFile) => mocha.addFile(testFile));
// exit with non-zero (error) status if there were failures
mocha.run((failures) => {
proc.on('exit', () => proc.exit(failures));
});
return testFiles;
};
示例2: Promise
return new Promise(function(resolve, reject) {
const testRunner = new Mocha();
testRunner.timeout(TIMEOUT);
testRunner.reporter('spec');
const files = glob.sync(`${TEST_DIR}/**/**.js`);
files.forEach(function(file) {
testRunner.addFile(file);
});
try {
testRunner.run(function(failures) {
process.exit(failures);
resolve();
});
} catch (err) {
return reject(err);
}
});
示例3: require
path = require('path');
// Instantiate a Mocha instance.
var mocha = new Mocha();
var testDir = 'uuid';
// Add each .js file to the mocha instance
fs.readdirSync(testDir).filter(function (file) {
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function (file) {
mocha.addFile(
path.join(testDir, file)
);
});
try {
// Run the tests.
mocha.run(function (failures) {
console.log(failures);
});
} catch (e) {
console.log('Erro ao executar os testes', e);
}
示例4: require
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const MochaTest = require('mocha');
const mochaTest = new MochaTest({
timeout: 60000,
slow: 10000,
useColors: true
});
mochaTest.addFile(require('path').join(process.cwd(), 'out/test.js'));
mochaTest.run((failures) => {
process.exit(failures);
});
示例5: require
process.env.TS_NODE_PROJECT = './tsconfig.spec.json';
import 'reflect-metadata';
require('ts-mocha');
const Mocha = require('mocha');
const mocha = new Mocha();
mocha.addFile(`./tests-ssr/todo.mocha.ts`);
mocha.addFile(`./tests-ssr/exit.mocha.ts`);
mocha.run((failures: number) => {
process.on('exit', () => {
process.exit(failures); // exit with non-zero status if there were failures
});
});