Getting test report json data in jest globalTeardown

24 Views Asked by At

How can I get result in the global teardown file?

const fs = require('fs').promises;
const os = require('os');
const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function () {
  // close the browser instance
  await globalThis.__BROWSER_GLOBAL__.close();

  // clean-up the wsEndpoint file
  await fs.rm(DIR, {recursive: true, force: true});
};

Source: https://jestjs.io/docs/puppeteer

I tried to use Jest with --json --outputFile and to get the json data in teardown.js, but apparently the file is written later.

How can I get that data in "teardown"?

0

There are 0 best solutions below