If you want to put temporary debug code into the application (which is a perfectly acceptable approach in my humble opinion, just remember to remove it before putting the code into production), don’t use
expect, instead try the
console global variable, for example
console.log("I want to know this");
console.warn("I wasn't expecting this");
These will all write messages to your console / terminal window when you run unit tests from it. On my PC, console.log writes in white, console.warn writes in a sort of yellow colour and console.error writes in red. The colours may be different on your machine but I think the principle stands for all platforms.
expect function is not, and should not, be defined, because it’s part of your test framework, it’s one of the things you use to verify that your code is ready to deploy into production. Once your code is in production, it doesn’t need (and shouldn’t use) the test framework, because by then the test framework has helped you to prove that your code is fit for deployment into production. Your unit tests and other tests need to know about the application that they’re testing, but the application doesn’t need to know anything about how it’s being tested or what frameworks are being used to test it, it just needs to know how to do its job.
I hope that edit clarifies more than it confuses:slightly_smiling_face: