https://cypress.io logo
Writing to node console from test:before:run/test:...
# i-need-help
p
Hello! I'd like to be able to print the start time and name of a test to our node console via these hooks. Currently, we have a task:
Copy code
beforeTest(testName) {
            console.log(
                colors.green(
                    `      ${getUTC()}: Start Time for Test (${testName}) ⏱️ `
                )
            )
            return null
        },
That is called in the
beforeEach
hook in our cypress/support/e2e.js file - this is also the same structure for our `afterTest`/`afterEach`. Using console.log in the test:before:run/test:after:run hooks, however, seems to only log it in the browser console, and you can't use tasks in these hooks. What can I do to make it print to the node console? Thanks in advance!
g
beforeEach
p
Just so I have it clear, I should keep the
beforeTest
call in the
beforeEach
hook in e2e.js?
g
yes
p
Gotcha, thank you!
4 Views