baseLayout.e2e.js 868 B

1234567891011121314151617181920212223242526272829303132333435
  1. import RouterConfig from '../../config/router.config';
  2. const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
  3. function formatter(data) {
  4. return data
  5. .reduce((pre, item) => {
  6. pre.push(item.path);
  7. return pre;
  8. }, [])
  9. .filter(item => item);
  10. }
  11. describe('Homepage', async () => {
  12. const testPage = path => async () => {
  13. await page.goto(`${BASE_URL}${path}`);
  14. await page.waitForSelector('footer', {
  15. timeout: 2000,
  16. });
  17. const haveFooter = await page.evaluate(
  18. () => document.getElementsByTagName('footer').length > 0
  19. );
  20. expect(haveFooter).toBeTruthy();
  21. };
  22. beforeAll(async () => {
  23. jest.setTimeout(1000000);
  24. await page.setCacheEnabled(false);
  25. });
  26. const routers = formatter(RouterConfig[1].routes);
  27. routers.forEach(route => {
  28. fit(`test pages ${route}`, testPage(route));
  29. });
  30. });