Earlier in the week I learned about the utility of console log groups in testing. Today one of the other project groups shared Console.groupCollapsed
which gives the default view in the console of all the test groups collapsed. This is much more useful when you have loads of tests and you don’t want to clutter the console!
function test(name, testFunction) { console.groupCollapsed(name); testFunction(); console.groupEnd(); } test("Example test 1", () => { console.log("test 1 log"); }); test("Example test 2", () => { console.log("test 2 log"); }); test("Example test 3", () => { console.log("test 2 log"); }); test("Example test 4", () => { console.log("test 2 log"); });
Outputs this to the console:
