userLayout.e2e.js 796 Bytes
Newer Older
陈帅's avatar
陈帅 committed
1 2
import RouterConfig from '../../config/router.config';

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

陈帅's avatar
陈帅 committed
5 6 7 8 9 10 11 12 13 14
function formatter(data) {
  return data
    .reduce((pre, item) => {
      pre.push(item.path);
      return pre;
    }, [])
    .filter(item => item);
}

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

  beforeAll(async () => {
陈帅's avatar
陈帅 committed
27
    jest.setTimeout(1000000);
陈帅's avatar
陈帅 committed
28
  });
陈帅's avatar
陈帅 committed
29 30
  formatter(RouterConfig[0].routes).forEach(route => {
    fit(`test pages ${route}`, testPage(route));
陈帅's avatar
陈帅 committed
31 32
  });
});