I have written a Node.js console script that colorizes its output, but only if the output is a TTY. If not, the output is not colorized.
Now I have a test that checks whether the output is colorized (I want to be sure that the right ANSI codes were added). This works great when running the unit tests manually using Grunt, but it fails when running the unit tests automatically using Jenkins.
The reason is plain obvious: Jenkins does not provide a TTY to my tests.
Now I have two options:
I don't like the first option, because this means that my tests are depending on the environment running them.
What do I need to do to be able to do the second thing?
For your tests how about using sinon and rewire to stub out tty.isatty()
so it returns true? You could test both true and false cases this way, as well.