How to use reportTests method in stryker-parent

Best JavaScript code snippet using stryker-parent

testRunner.ts

Source:testRunner.ts Github

copy

Full Screen

...8import * as namespace from './namespace';9import { getSession, updateReplSessionType } from './nrepl/repl-session';10import * as getText from './util/get-text';11let diagnosticCollection = vscode.languages.createDiagnosticCollection('calva');12function reportTests(results, errorStr, log = true) {13 let diagnostics = {};14 let total_summary: { test, error, ns, var, fail } = { test: 0, error: 0, ns: 0, var: 0, fail: 0 };15 diagnosticCollection.clear();16 if (results.err || results.ex) {17 util.logError({18 type: util.ERROR_TYPE.ERROR,19 reason: "Error " + errorStr + ":" + results.err20 });21 } else {22 for (let result of results) {23 for (const ns in result.results) {24 let resultSet = result.results[ns];25 for (const test in resultSet) {26 for (const a of resultSet[test]) {27 for (const prop in a) {28 if (typeof (a[prop]) === 'string') {29 a[prop] = a[prop].replace(/\r?\n$/, "");30 }31 }32 const resultMessage = (resultItem) => {33 let msg = [];34 if (!_.isEmpty(resultItem.context) && resultItem.context !== "false")35 msg.push(resultItem.context);36 if (resultItem.message)37 msg.push(resultItem.message);38 return `${msg.length > 0 ? msg.join(": ").replace(/\r?\n$/, "") : ''}`;39 }40 if (a.type === "error" && log) {41 const rMsg = resultMessage(a);42 outputWindow.append(`; ERROR in ${ns}/${test} (line ${a.line}):`);43 if (rMsg !== '') {44 outputWindow.append(`; ${resultMessage(a)}`);45 }46 outputWindow.append(`; error: ${a.error} (${a.file})\n; expected:\n${a.expected}`);47 }48 if (a.type === "fail") {49 const rMsg = resultMessage(a);50 let msg = `failure in test: ${test} context: ${a.context}, expected ${a.expected}, got: ${a.actual}`,51 err = new vscode.Diagnostic(new vscode.Range(a.line - 1, 0, a.line - 1, 1000), msg, vscode.DiagnosticSeverity.Error);52 if (!diagnostics[a.file])53 diagnostics[a.file] = [];54 diagnostics[a.file].push(err);55 if (log) {56 outputWindow.append(`; FAIL in ${ns}/${test} (${a.file}:${a.line}):`);57 if (rMsg !== '') {58 outputWindow.append(`; ${resultMessage(a)}`);59 }60 outputWindow.append(`; expected:\n${a.expected}\n; actual:\n${a.actual}`);61 }62 }63 }64 }65 }66 if (result.summary !== null) {67 _.each(result.summary, (v, k) => {68 total_summary[k] = result.summary[k] + (total_summary[k] !== undefined ? total_summary[k] : 0);69 });70 }71 }72 if (total_summary !== null) {73 let hasProblems = total_summary.error + total_summary.fail > 0;74 if (log) {75 outputWindow.append("; " + (total_summary.test > 0 ?76 total_summary.test + " tests finished, " +77 (!hasProblems ? "all passing 👍" :78 "problems found. 😭" +79 " errors: " + total_summary.error + ", failures: " + total_summary.fail) : "No tests found. 😱") +80 ", ns: " + total_summary.ns + ", vars: " + total_summary.var);81 }82 if (total_summary.test > 0) {83 if (hasProblems) {84 _.each(diagnostics, (errors, fileName) => {85 if (fileName.startsWith('/'))86 diagnosticCollection.set(vscode.Uri.file(fileName), errors);87 else {88 // Sometimes we don't get the full path for some reason. (This is a very inexact89 // way of dealing with that. Maybe check for the right `ns`in the file?)90 vscode.workspace.findFiles('**/' + fileName, undefined).then((uri) => {91 diagnosticCollection.set(uri[0], errors);92 });93 }94 });95 }96 }97 }98 }99}100// FIXME: use cljs session where necessary101async function runAllTests(document = {}) {102 const session = getSession(util.getFileType(document));103 outputWindow.append("; Running all project tests…");104 reportTests([await session.testAll()], "Running all tests");105 updateReplSessionType();106 outputWindow.appendPrompt();107}108function runAllTestsCommand() {109 if (!util.getConnectedState()) {110 vscode.window.showInformationMessage('You must connect to a REPL server to run this command.')111 return;112 }113 runAllTests().catch(() => { });114}115async function considerTestNS(ns: string, session: NReplSession, nss: string[]): Promise<string[]> {116 if (!ns.endsWith('-test')) {117 const testNS = ns + '-test';118 const nsPath = await session.nsPath(testNS);119 const testFilePath = nsPath.path;120 if (testFilePath && testFilePath !== "") {121 const filePath = vscode.Uri.parse(testFilePath).path;122 let loadForms = `(load-file "${filePath}")`;123 await session.eval(loadForms, testNS).value;124 }125 nss.push(testNS);126 return nss;127 }128 return nss;129}130async function runNamespaceTests(document = {}) {131 const doc = util.getDocument(document);132 if (outputWindow.isResultsDoc(doc)) {133 return;134 }135 if (!util.getConnectedState()) {136 vscode.window.showInformationMessage('You must connect to a REPL server to run this command.')137 return;138 }139 const session = getSession(util.getFileType(document));140 const ns = namespace.getNamespace(doc);141 let nss = [ns];142 await evaluate.loadFile({}, disabledPrettyPrinter);143 outputWindow.append(`; Running tests for ${ns}...`);144 nss = await considerTestNS(ns, session, nss);145 const resultPromises = [session.testNs(nss[0])];146 if (nss.length > 1) {147 resultPromises.push(session.testNs(nss[1]));148 }149 const results = await Promise.all(resultPromises);150 reportTests(results, "Running tests");151 outputWindow.setSession(session, ns);152 updateReplSessionType();153 outputWindow.appendPrompt();154}155function getTestUnderCursor() {156 const editor = vscode.window.activeTextEditor;157 if (editor) {158 return getText.currentTopLevelFunction(editor)[1];159 }160}161async function runTestUnderCursor() {162 const doc = util.getDocument({});163 const session = getSession(util.getFileType(doc));164 const ns = namespace.getNamespace(doc);165 const test = getTestUnderCursor();166 if (test) {167 await evaluate.loadFile(doc, disabledPrettyPrinter);168 outputWindow.append(`; Running test: ${test}…`);169 const results = [await session.test(ns, test)];170 reportTests(results, `Running test: ${test}`);171 } else {172 outputWindow.append('; No test found at cursor');173 }174 outputWindow.appendPrompt();175}176function runTestUnderCursorCommand() {177 if (!util.getConnectedState()) {178 vscode.window.showInformationMessage('You must connect to a REPL server to run this command.')179 return;180 }181 runTestUnderCursor().catch(() => { });182}183function runNamespaceTestsCommand() {184 if (!util.getConnectedState()) {185 vscode.window.showInformationMessage('You must connect to a REPL server to run this command.')186 return;187 }188 runNamespaceTests();189}190async function rerunTests(document = {}) {191 let session = getSession(util.getFileType(document))192 await evaluate.loadFile({}, disabledPrettyPrinter);193 outputWindow.append("; Running previously failed tests…");194 reportTests([await session.retest()], "Retesting");195 outputWindow.appendPrompt();196}197function rerunTestsCommand() {198 if (!util.getConnectedState()) {199 vscode.window.showInformationMessage('You must connect to a REPL server to run this command.')200 return;201 }202 rerunTests();203}204export default {205 runNamespaceTests,206 runNamespaceTestsCommand,207 runAllTestsCommand,208 rerunTestsCommand,...

Full Screen

Full Screen

run.js

Source:run.js Github

copy

Full Screen

...23var timeout = setTimeout(function () {24 console.error(`Timeout. ${testsPassed} tests passed, ${testsFailed} tests failed, ${2 * ALL_TESTS - testsPassed - testsFailed} tests pending.`);25 process.exit(1);26}, 5 * 1000); // ms27var reportTests = function reportTests() {28 if (testsPassed === 2 * ALL_TESTS && testsFailed === 0) {29 console.log(`All ${testsPassed} tests passed.`);30 clearTimeout(timeout);31 process.exit(0);32 }33 else if (testsPassed + testsFailed >= 2 * ALL_TESTS) {34 console.error(`${testsPassed} tests passed, ${testsFailed} tests failed.`);35 clearTimeout(timeout);36 process.exit(1);37 }38};39var bufferToTime = function bufferToTime(buffer) {40 var view = new DataView(new Uint8Array(buffer).buffer);41 return view.getUint32(0, true) + view.getUint32(4, true) * Math.pow(2, 32);42};43var mockWorker = new MockSecureWorker('enclave.so', 'test.js');44var realWorker = new RealSecureWorker('enclave.so', 'test.js');45[{name: "Mock", worker: mockWorker}, {name: "Real", worker: realWorker}].forEach(function (type) {46 type.worker.onMessage(function (message) {47 if (message.success === true) {48 console.log(type.name + " test passed: " + message.name);49 testsPassed++;50 reportTests();51 }52 else if (message.success === false) {53 console.error(type.name + " test failed: " + message.name);54 testsFailed++;55 reportTests();56 }57 });58 var previousTime = null;59 var timeSourceNonce = null;60 type.worker.onMessage(function listener(message) {61 if (message.command !== 'time') return;62 if (!previousTime && !timeSourceNonce) {63 previousTime = Buffer.from(message.currentTime, 'base64');64 timeSourceNonce = Buffer.from(message.timeSourceNonce, 'base64');65 setTimeout(function () {66 type.worker.postMessage({command: 'time'});67 }, 1000); // ms68 }69 else {70 type.worker.removeOnMessage(listener);71 var newTime = Buffer.from(message.currentTime, 'base64');72 if (!Buffer.from(message.timeSourceNonce, 'base64').equals(timeSourceNonce)) {73 console.error("Time nonce changed.");74 testsFailed++;75 reportTests();76 return;77 }78 if (bufferToTime(newTime) === bufferToTime(previousTime) + 1) {79 console.log(type.name + " test passed: trusted time");80 testsPassed++;81 reportTests();82 }83 else {84 console.error(type.name + " test failed: trusted time");85 testsFailed++;86 reportTests();87 }88 }89 });90 type.worker.postMessage({command: 'time'});91 var data = crypto.randomBytes(64);92 type.worker.onMessage(function listener(message) {93 if (message.command !== 'report') return;94 type.worker.removeOnMessage(listener);95 var report = new Uint8Array(Buffer.from(message.report, 'base64').values()).buffer;96 var reportData = type.worker.constructor.getReportData(report);97 if (_.isEqual(new Uint8Array(data), new Uint8Array(reportData))) {98 console.log(type.name + " test passed: report data");99 testsPassed++;100 }101 else {102 console.error(type.name + " test failed: report data");103 testsFailed++;104 }105 try {106 var quote = type.worker.constructor.getQuote(report, false, new ArrayBuffer(16));107 var quoteData = type.worker.constructor.getQuoteData(quote);108 if (_.isEqual(new Uint8Array(data), new Uint8Array(quoteData))) {109 console.log(type.name + " test passed: quote data");110 testsPassed++;111 }112 else {113 console.error(type.name + " test failed: quote data");114 testsFailed++;115 }116 }117 catch (error) {118 console.error(error);119 console.error(type.name + " test failed: quote data");120 testsFailed++;121 }122 reportTests();123 });124 type.worker.postMessage({125 command: 'report',126 reportData: data.toString('base64')127 });128});...

Full Screen

Full Screen

schema.js

Source:schema.js Github

copy

Full Screen

1import { Mongo } from 'meteor/mongo';2import { Class } from 'meteor/jagi:astronomy';3import _ from 'lodash';4import Author from '../../behaviors/author.js';5import TimeTracked from '../../behaviors/timetracked.js';6import Content from '../../schemas/content/schema.js';7import User from '../users/schema.js';8const Attempts = new Mongo.Collection('attempts');9const AttemptScoreSchema = Class.create({10 name: 'AttemptScore',11 fields: {12 name: String,13 parent: {14 type: Object,15 optional: true,16 },17 description: {18 type: [Object],19 optional: true,20 },21 _id: String,22 score: Number,23 },24});25const Attempt = Class.create({26 name: 'Attempt',27 collection: Attempts,28 fields: {29 test: {30 type: Object,31 immutable: true,32 },33 sudoku: {34 type: Object,35 optional: true,36 },37 finished: {38 type: Boolean,39 default: false,40 },41 scores: {42 type: [AttemptScoreSchema],43 optional: true,44 default: () => [],45 },46 },47 behaviors: {48 timestamp: {49 hasCreatedField: true,50 createdFieldName: 'createdAt',51 hasUpdatedField: true,52 updatedFieldName: 'updatedAt',53 },54 },55 events: {56 afterUpdate({ currentTarget: attempt }) {57 if (attempt.finished) {58 const author = User.findOne({ _id: _.get(attempt, 'author._id') });59 const { test } = attempt;60 _.forEach(attempt.scores, score => {61 const index = _.findIndex(author.report, { _id: score._id });62 if (index >= 0) {63 const report = author.report[index];64 report.score = (report.score || 0) + score.score;65 if (report.tests[test._id])66 report.tests[test._id].push(attempt._id);67 else68 report.tests[test._id] = [attempt._id];69 }70 else {71 author.report.push(72 new User.UserReportSchema({73 ...score.raw(),74 tests: { [attempt.test._id]: [attempt._id] },75 })76 );77 }78 let parent = score.parent;79 while (parent) {80 const parentIndex = _.findIndex(author.report, { _id: parent._id });81 if (parentIndex < 0) {82 author.report.push(83 new User.UserReportSchema({84 ...parent,85 tests: { [test._id]: [attempt._id] },86 })87 );88 } else {89 const reportTests = author.report[parentIndex].tests;90 if (reportTests[test._id]) {91 const attemptIndex = reportTests[test._id].indexOf(attempt._id);92 if (attemptIndex < 0)93 reportTests[test._id].push(attempt._id);94 }95 else96 reportTests[test._id] = [attempt._id];97 };98 parent = parent.parent;99 };100 });101 author.save();102 }103 },104 },105});106Author(Attempt);107TimeTracked(Attempt);108Attempt.AttemptScoreSchema = AttemptScoreSchema;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { reportTests } = require('stryker-parent');2reportTests(['test1', 'test2']);3module.exports = function(config) {4 config.set({5 jest: {6 config: require('./jest.config.js'),7 },8 { pattern: 'test.js', mutated: false, included: true },9 });10};

Full Screen

Using AI Code Generation

copy

Full Screen

1var reportTests = require('stryker-parent').reportTests;2 { id: 'test1', name: 'should do something', timeSpentMs: 5 },3 { id: 'test2', name: 'should do something else', timeSpentMs: 10 }4];5reportTests(tests);6var reportTestResults = require('stryker-parent').reportTestResults;7 { id: 'test1', name: 'should do something', status: 'passed', timeSpentMs: 5 },8 { id: 'test2', name: 'should do something else', status: 'failed', timeSpentMs: 10 }9];10reportTestResults(results);

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.reportTests();3var strykerParent = require('stryker-parent');4strykerParent.reportTests();5var strykerParent = require('stryker-parent');6strykerParent.reportTests();7var strykerParent = require('stryker-parent');8strykerParent.reportTests();9var strykerParent = require('stryker-parent');10strykerParent.reportTests();11var strykerParent = require('stryker-parent');12strykerParent.reportTests();13var strykerParent = require('stryker-parent');14strykerParent.reportTests();

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = require('stryker-parent').reportTests;2test('test1', 'test1', 'test1', 100);3test('test2', 'test2', 'test2', 100);4test('test3', 'test3', 'test3', 100);5var reportTests = function (name, description, suite, time) {6 console.log('name: ' + name + ', description: ' + description + ', suite: ' + suite + ', time: ' + time);7};8module.exports = {9};

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 reportTests: function (results) {3 console.log(results);4 }5};6module.exports = function(config) {7 config.set({8 });9}10module.exports = function(config) {11 config.set({12 });13}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful