Skip to content

Commit

Permalink
Merge branch 'devel' into MX002-11412
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcctech committed Apr 6, 2024
2 parents 304c3c4 + 791f2e6 commit 17e0e6e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
27 changes: 20 additions & 7 deletions packages/test-in-console/puppeteerRunner.js
Expand Up @@ -5,12 +5,29 @@ let testNumber = 0;
async function runNextUrl(browser) {
const page = await browser.newPage();

page.on('console', msg => {
page.on('console', async msg => {
// this is a way to make sure the travis does not timeout
// if the test is running for too long without any output to the console (10 minutes)
if (msg._text !== undefined) console.log(msg._text);
else console.log(`Test number: ${ testNumber }`);
testNumber++;
else {
testNumber++;
const currentClientTest =
await page.evaluate(() => __Tinytest._getCurrentRunningTestOnClient());
if (currentClientTest !== '') {
console.log(`Currently running on the client test: ${ currentClientTest }`)
return;
}
// If we get here is because we have not yet started the test on the client
const currentServerTest =
await page.evaluate(async () => await __Tinytest._getCurrentRunningTestOnServer());

if (currentServerTest !== '') {
console.log(`Currently running on the server test: ${ currentServerTest }`);
return;
}
// we were not able to find the name of the test, this is a way to make sure the test is still running
console.log(`Test number: ${ testNumber }`);
}
});

if (!process.env.URL) {
Expand All @@ -23,10 +40,6 @@ async function runNextUrl(browser) {
async function poll() {
if (await isDone(page)) {
let failCount = await getFailCount(page);
console.log(`
The number of tests from Test number may be different because
of the way the test is written. causing the test to fail or
to run more than once. in the console. Test number total: ${ testNumber }`);
console.log(`Tests complete with ${ failCount } failures`);
console.log(`Tests complete with ${ await getPassCount(page) } passes`);
if (failCount > 0) {
Expand Down
19 changes: 18 additions & 1 deletion packages/tinytest/tinytest.js
Expand Up @@ -531,7 +531,7 @@ export class TestRun {

_runTest(test, onComplete, stop_at_offset) {
var startTime = (+new Date);

Tinytest._currentRunningTestName = test.name;
test.run(event => {
/* onEvent */
// Ignore result callbacks if the test has already been reported
Expand Down Expand Up @@ -671,6 +671,7 @@ export class TestRun {
/******************************************************************************/

export const Tinytest = {};
globalThis.__Tinytest = Tinytest;

Tinytest.addAsync = function (name, func, options) {
TestManager.addCase(new TestCase(name, func), options);
Expand Down Expand Up @@ -701,6 +702,22 @@ Tinytest._runTests = function (onReport, onComplete, pathPrefix) {
testRun.run(onComplete);
};

Tinytest._currentRunningTestName = ""

Meteor.methods({
'tinytest/getCurrentRunningTestName'() {
return Tinytest._currentRunningTestName;
}
})

Tinytest._getCurrentRunningTestOnServer = function () {
return Meteor.callAsync('tinytest/getCurrentRunningTestName');
}

Tinytest._getCurrentRunningTestOnClient = function () {
return Tinytest._currentRunningTestName;
}

// Run just one test case, and stop the debugger at a particular
// error, all as indicated by 'cookie', which will have come from a
// failure event output by _runTests.
Expand Down

0 comments on commit 17e0e6e

Please sign in to comment.