Commit b042b097 authored by afc163's avatar afc163

Fix test case timeout

parent 67fccc35
...@@ -19,44 +19,23 @@ describe('Homepage', () => { ...@@ -19,44 +19,23 @@ describe('Homepage', () => {
let browser; let browser;
let page; let page;
const testAllPage = async layout => const testPage = path => async () => {
new Promise(async (resolve, reject) => { await page.goto(`${BASE_URL}${path}`, { waitUntil: 'networkidle2' });
const loadPage = async index => { const haveFooter = await page.evaluate(
const path = layout[index]; () => document.getElementsByTagName('footer').length > 0
try { );
await page.goto(`${BASE_URL}${path}`, { waitUntil: 'networkidle2' }); expect(haveFooter).toBeTruthy();
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);
});
beforeAll(async () => { beforeAll(async () => {
browser = await puppeteer.launch({ args: ['--no-sandbox'] }); browser = await puppeteer.launch({ args: ['--no-sandbox'] });
page = await browser.newPage(); page = await browser.newPage();
jest.setTimeout(1000000);
}); });
it('test user layout', async () => { RouterConfig.forEach(({ routes = [] }) => {
const userLayout = formatter(RouterConfig[0].routes); formatter(routes).forEach(route => {
await testAllPage(userLayout); it(`test pages ${route}`, testPage(route));
}); });
it('test base layout', async () => {
const baseLayout = formatter(RouterConfig[1].routes);
await testAllPage(baseLayout);
}); });
afterAll(() => browser.close()); afterAll(() => browser.close());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment