Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a test written in java script that produces a large amount of console outputs.
passed and failed scenarios

I just want the FAILED "SCENARIO# FAILED" TO DISPLAY
AND "SCENARIO# PASSED" NOT TO

Because I want to save this failed scenarios in txt file on my desktop.
So basically 'the failed scenarios will be saved in a log file.


I tried the code below nd I am getting errors that
logger.disableLogger();
is NOT a fucntion

What I have tried:

<pre> var logger = function()
{
    var oldConsoleLog = null;
    var pub = {};

    pub.enableLogger =  function enableLogger() 
                        {
                            if(oldConsoleLog == null)
                                return;

                            window['console']['log'] = oldConsoleLog;
                        };

    pub.disableLogger = function disableLogger()
                        {
                            oldConsoleLog = console.log;
                            window['console']['log'] = function() {};
                        };

    return pub;
}();
var exampleof_passedscenario="SCENARIO#1: PASSED";

 logger.disableLogger();
console.log(exampleof_passedscenario);
Posted
Updated 5-May-21 4:32am

1 solution

Figured out my own question
Just needed to change console.log()==>
disableLogger();
<pre> logger.disableLogger();
console.log(exampleof_passedscenario);


Changed console log();
logger.disableLogger(exampleof_passedscenario);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900