diff --git a/packages/test-in-console/puppeteerRunner.js b/packages/test-in-console/puppeteerRunner.js index 3400986b7f..d0a59ae9c9 100644 --- a/packages/test-in-console/puppeteerRunner.js +++ b/packages/test-in-console/puppeteerRunner.js @@ -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) { @@ -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) { diff --git a/packages/tinytest/tinytest.js b/packages/tinytest/tinytest.js index b1315adc59..3427db1c86 100644 --- a/packages/tinytest/tinytest.js +++ b/packages/tinytest/tinytest.js @@ -531,6 +531,7 @@ export class TestRun { _runTest(test, onComplete, stop_at_offset) { var startTime = (+new Date); + Tinytest._currentRunningTestName = test.name; return test.run(event => { /* onEvent */ @@ -671,6 +672,7 @@ export class TestRun { /******************************************************************************/ export const Tinytest = {}; +globalThis.__Tinytest = Tinytest; Tinytest.addAsync = function (name, func, options) { TestManager.addCase(new TestCase(name, func), options); @@ -701,6 +703,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.