Search code examples
angularjsseleniumjasmineprotractorjasmine-node

Is there a way I can change colors of text output in Jasmine?


I am using protractor for my AngularJS E2E testing. I use the DOS command line with a white background and black test.

I have the following set up:

  jasmineNodeOpts: {
      isVerbose: true,
    showColors: true,
    defaultTimeoutInterval: 30000,
      stackTrace: false
  }

What happens is that I see the first few lines in black on white:

C:\Test\NodejsConsoleApp1\NodejsConsoleApp1>node_modules\.bin\protractor conf.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Homepage1
    Open a page with an id of ng-app

Then the text background changes to black and I see black, red and green on a dark background.

Is there a way I can change this?


Solution

  • not sure if there is a better/cleaner way (maybe a config file, i don't know...)

    i got interested and searched 'color' in node_modules/protractor and found this in node_modules/protractor/lib/cli.js starting at line 47

        ANSIColors: {
           pass:    function() { return '\033[32m'; }, // Green
           fail:    function() { return '\033[31m'; }, // Red
           neutral: function() { return '\033[0m';  }  // Normal
        }
    

    color code cheat sheet

    anyway, strange behavior of your console to change its background color. windows console has an option to set its appearance and save it (by its console name..? i am on linux now, cant check). not sure if this helps preventing the console from changing its color by it self.