UNPKG

teamsfx-extension

Version:

Create, debug, and deploy Teams apps with Teams Toolkit

63 lines 2.75 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const path = require("path"); const Mocha = require("mocha"); const glob = require("glob"); function run() { return __awaiter(this, void 0, void 0, function* () { const options = { ui: "tdd", color: true, reporter: "mocha-multi-reporters", reporterOptions: { reporterEnabled: "spec, mocha-junit-reporter", mochaJunitReporterReporterOptions: { mochaFile: path.resolve(__dirname, "..", "..", "test-results.nofolder.xml"), }, }, }; addEnvVarsToMochaOptions(options); console.log(`Mocha options: ${JSON.stringify(options, undefined, 2)}`); const mocha = new Mocha(options); const testsRoot = path.resolve(__dirname); const files = yield new Promise((resolve, reject) => { glob("suite/**/**.noFolder.test.js", { cwd: testsRoot }, (err, result) => { err ? reject(err) : resolve(result); }); }); files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); const failures = yield new Promise((resolve) => mocha.run(resolve)); if (failures > 0) { throw new Error(`${failures} tests failed.`); } }); } exports.run = run; function addEnvVarsToMochaOptions(options) { for (const envVar of Object.keys(process.env)) { const match = envVar.match(/^mocha_(.+)/i); if (match) { const [, option] = match; // tslint:disable-next-line:strict-boolean-expressions let value = process.env[envVar] || ""; if (typeof value === "string" && !isNaN(parseInt(value))) { value = parseInt(value); } // tslint:disable-next-line: no-any options[option] = value; } } } //# sourceMappingURL=index.noFolder.js.map