I am running jest.RunCLI({},'path');
I have a custom reporter class and all is working well.
I want to add more data to the results. From each test. For example if I want to return specific test failure information that would help in future debugging.
const projectRootPath = path.join(process.cwd(),'myproject');
const jestConfig = {
automock: false,
bail: 0,
json: false,
rootDir: '/home/user/myprojects/tests',
reporters: ['../custom-reporter.cjs']
};
jest.runCLI(jestConfig, [projectRootPath])
.then((result)=>{
console.log = console_log;
})
.catch((e)=>{
console.log(e);
});
Now supposing I have a test file that contains
describe('My tests', ()=>{
it('Does a test',()=>{
//How can I return this to the aggregated results?
let reallyImportant = 'Really must log this somewhere useful, with the results would be good';
});
});
See comment line for the question in context.
So far I have tried monkey patching the jest object. Didn't work. Tried redirecting console.log. Doesn't work for any console logs inside the test fixture.
Any ideas?