mercredi 5 juin 2019

How can I design reusable code in function for testing in Puppeteer?

I code test in puppeteer with jest:

How to create reusable function for similar login tests without code repeating?

  describe('new user test', () => {
    test('no existed user try', async() => {
  browser = await puppeteer.launch(chromeOptions)
  const page = await browser.newPage();

  await page.goto("https://admin.manager.synthrone.com/") 

  await page.waitForSelector('#mat-input-0')
  await page.type('#mat-input-0', 'test')
  await page.type('#mat-input-1', 'pass')
  await page.click('button')

Aucun commentaire:

Enregistrer un commentaire