baseLayout.e2e.js 867 Bytes
Newer Older
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import RouterConfig from '../../config/router.config';

const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;

function formatter(data) {
  return data
    .reduce((pre, item) => {
      pre.push(item.path);
      return pre;
    }, [])
    .filter(item => item);
}

describe('Homepage', async () => {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
15 16 17 18
  const testPage = path => async () => {
    await page.goto(`${BASE_URL}${path}`);
    await page.waitForSelector('footer', {
      timeout: 2000,
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
19
    });
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
20 21 22 23 24
    const haveFooter = await page.evaluate(
      () => document.getElementsByTagName('footer').length > 0
    );
    expect(haveFooter).toBeTruthy();
  };
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
25 26 27 28 29

  beforeAll(async () => {
    jest.setTimeout(1000000);
    await page.setCacheEnabled(false);
  });
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
30 31
  const routers = formatter(RouterConfig[1].routes);
  routers.forEach(route => {
32
    it(`test pages ${route}`, testPage(route));
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
33 34
  });
});