I'm using a custom jest reporter to populate data in testrail (a test case management software) and would like my jest tests to be the source of truth for all data being fed into the test case management software.
I've been struggling a bit to understand how I could pass additional data from the test to the reporter. I'm testing a GraphQL API, and would like the actual API payload to make its way, from the test to testrail, plus eventually additional metadata later on.
The only data elements I'm able to use are:
ancestorTitles: [Array],
duration: 52,
failureMessages: [],
fullName: 'Test suite - test case',
location: null,
numPassingAsserts: 0,
status: 'passed',
title: 'test case'
For example, a test case looks like this:
describe('My Test Suite', () => {
test('My test case', async done => {
const query = `
{
query {
documents {
totalCount
}
}
}`
const response = await graphQL(query, global.apiConfig)
const hits = response.data.documents.totalCount
expect(hits).toHaveLength(4)
done();
}
)
How could I have query passed down to the reporter?