mardi 6 août 2019

Let Puppeteer wait for globalSetup to finish

I use Jest-Puppeteer to end2end test a webapplication. All tests run parallel with async functions. Now I find that the first test already runs before the globalSetup has finished and the data preperation is done (initializing client-settings etc.)

I've tried to timeout after the request, but that isn't working because now all requests have a timeout.

import puppeteer from "puppeteer";

import { getUrlByPath, post } from "../helper";

module.exports = async function globalSetup(globalConfig) {
  await setupPuppeteer(globalConfig);

  puppeteer.launch({args: ["--no-sandbox", "--disable-setuid-sandbox"]}).then(async browser => {
    const page = await browser.newPage();

    await post(
      page,
      getUrlByPath("somePath"),
      "prepare_data_for_testing",
    );

    await browser.close();
  });
};

Above code runs a globalConfig, after that it starts preparing the data for the testing environment.

Is there a way to make the test suites run AFTER this script returns the post with http 200: ok ?

Aucun commentaire:

Enregistrer un commentaire