You can adjust the environment variables cmake runs with by editing the CMakePresets.json file.
Merge in this json snippet to print test output on test failures.
{
"configurePresets": [
{
"environment": {
"CTEST_OUTPUT_ON_FAILURE": "ON"
}
}
]
}