W
W
wqqe2021-06-29 11:00:47
Unit testing
wqqe, 2021-06-29 11:00:47

Why is it throwing an error when running the e2e test?

I wrote a test and it doesn't pass. When run, it throws an error: Execution context was destroyed, most likely because of a navigation.
Here is the test:

import puppeteer from 'puppeteer';

describe('ff', () => {
  test('dd', async () => {
    const browser = await puppeteer.launch({
      headless: false,
      slowMo: 100,
    });
    const page = await browser.newPage();

    page.goto('http://localhost:3000/photos/list');

    page.click('[data-hook="changeSearchState"]');
    page.click('input[data-hook="searchField"]');
    page.type('input[data-hook="searchField"]', 'officia');

    const cards = await page.evaluate(() =>
      Array.from(
        document.querySelectorAll('div[data-hook="cardPhoto"]'),
        (elem) => elem.textContent
      )
    );

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


Path I checked, it is correct.
What could be the problem ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question