Open Sergio-Mira opened 6 years ago
var page = require('webpage').create();
var system = require('system');
var url = system.args[1];
var resultProcessed = false; // Guard to prevent multiple result processing
page.onConsoleMessage = function(msg) {
system.stdout.writeLine(msg);
};
page.onCallback = function(data) {
if (resultProcessed) {
return; // Guard: Exit if results have already been processed
}
if (data && data.type === 'result') {
resultProcessed = true; // Set guard
var result = JSON.stringify(data);
system.stdout.writeLine(result);
}
};
page.open(url, function(status) {
if (status !== 'success') {
console.log('Unable to access network');
phantom.exit(1);
} else {
page.evaluate(function() {
if (typeof window.callPhantom === 'function') {
window.callPhantom({
type: 'result',
elapsed: '234.24000',
_teaspoon: true
});
}
});
}
});
We are using PhantomJS and for some reason it is reporting the same result line 3 times, which makes Teaspoon consider that it has results 3 times in a row:
{"type":"result","elapsed":"234.24000","_teaspoon":true}
Unfortunately that means test results are being printed 3 times too and it generates broken JUnit reports as too many closing tags are added.
Is there any possibility that a guard against multiple calls with
result
could be added to notify_formatters?