Update to get testname in the client

This commit is contained in:
Gabriel Grubba
2024-04-03 16:04:06 -03:00
parent c2eb586f27
commit 60e2dd67bb
2 changed files with 10 additions and 16 deletions

View File

@@ -10,11 +10,10 @@ async function runNextUrl(browser) {
// 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 {
// sometimes if the test is running in the client we have id: current-client-test with
// the name of the test
const element = await page.$('#current-client-test');
if (element) {
const currentClientTest = await page.evaluate(element => element.textContent, element);
testNumber++;
const currentClientTest =
await page.evaluate(() => __Tinytest._getCurrentRunningTestOnClient());
if (currentClientTest !== '') {
console.log(`Currently running on the client test: ${ currentClientTest }`)
return;
}
@@ -29,7 +28,6 @@ async function runNextUrl(browser) {
// 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 }`);
}
testNumber++;
});
if (!process.env.URL) {
@@ -42,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) {

View File

@@ -531,9 +531,7 @@ export class TestRun {
_runTest(test, onComplete, stop_at_offset) {
var startTime = (+new Date);
if (Meteor.isServer){
Tinytest._currentRunningTestNameOnServer = test.name;
}
Tinytest._currentRunningTestName = test.name;
return test.run(event => {
/* onEvent */
@@ -705,19 +703,21 @@ Tinytest._runTests = function (onReport, onComplete, pathPrefix) {
testRun.run(onComplete);
};
Tinytest._currentRunningTestNameOnServer = ""
Tinytest._currentRunningTestName = ""
Meteor.methods({
'tinytest/getCurrentRunningTestName'() {
return Tinytest._currentRunningTestNameOnServer;
return Tinytest._currentRunningTestName;
}
})
// Get current running test from server;
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