Hundreds of automated tests to verify calculations, written using Jest's jest.each
feature, need to be presented to decision-makers in another, more legible form. A typical test suite would start something like this (example numbers):
describe('Drug 1', () => {
test.each`
weight | vial | expectedMg | expectedMl | clinicalCaseNumber
${140} | ${250} | ${10} | ${2} | ${'I13'}
${140} | ${500} | ${10} | ${1} | ${'I14'}
I would like to access the test data in my *.test.js
files from the React app being tested so that permissioned users can review the automated tests being run.
I had hoped to do something like this:
export const DRUGS = {};
DRUGS['Drug 1'] = `
weight | vial | expectedMg | expectedMl | clinicalCaseNumber
${140} | ${250} | ${10} | ${2} | ${'I13'}
${140} | ${500} | ${10} | ${1} | ${'I14'}
And then use the template literals both with test.each
here and within the application. However, this doesn't seem to be possible?
You can create a separate script as an entry point
package.json
You can reuse jest-each to define a global test function and create the desired output
scripts/dump.js