diff --git a/src/e2e/layout.e2e.js b/src/e2e/layout.e2e.js index fa5edfd2e4faa8ebc7d8ae31f3d52813596aaf45..58525bc98bfbb8da3079074bf1f870b626caa6c8 100644 --- a/src/e2e/layout.e2e.js +++ b/src/e2e/layout.e2e.js @@ -19,44 +19,23 @@ describe('Homepage', () => { let browser; let page; - const testAllPage = async layout => - new Promise(async (resolve, reject) => { - const loadPage = async index => { - const path = layout[index]; - try { - await page.goto(`${BASE_URL}${path}`, { waitUntil: 'networkidle2' }); - const haveFooter = await page.evaluate( - () => document.getElementsByTagName('footer').length > 0 - ); - - expect(haveFooter).toBeTruthy(); - - if (index < layout.length - 1) { - loadPage(index + 1); - } else { - resolve('ok'); - } - } catch (error) { - reject(error); - } - }; - loadPage(0); - }); + const testPage = path => async () => { + await page.goto(`${BASE_URL}${path}`, { waitUntil: 'networkidle2' }); + const haveFooter = await page.evaluate( + () => document.getElementsByTagName('footer').length > 0 + ); + expect(haveFooter).toBeTruthy(); + }; beforeAll(async () => { browser = await puppeteer.launch({ args: ['--no-sandbox'] }); page = await browser.newPage(); - jest.setTimeout(1000000); }); - it('test user layout', async () => { - const userLayout = formatter(RouterConfig[0].routes); - await testAllPage(userLayout); - }); - - it('test base layout', async () => { - const baseLayout = formatter(RouterConfig[1].routes); - await testAllPage(baseLayout); + RouterConfig.forEach(({ routes = [] }) => { + formatter(routes).forEach(route => { + it(`test pages ${route}`, testPage(route)); + }); }); afterAll(() => browser.close());