Commit 802930e7 authored by 陈帅's avatar 陈帅

fix test script

parent f3ec5fa9
......@@ -12,35 +12,23 @@ function formatter(data) {
}
describe('Homepage', async () => {
const testPage = path =>
new Promise(async reslove => {
console.log(`test ${path}`);
await page.goto(`${BASE_URL}${path}`, {
timeout: 600000,
});
await page.waitForSelector('footer', {
timeout: 600000,
});
reslove();
const testPage = path => async () => {
await page.goto(`${BASE_URL}${path}`);
await page.waitForSelector('footer', {
timeout: 2000,
});
const haveFooter = await page.evaluate(
() => document.getElementsByTagName('footer').length > 0
);
expect(haveFooter).toBeTruthy();
};
beforeAll(async () => {
jest.setTimeout(1000000);
await page.setCacheEnabled(false);
});
it(`test pages`, async () => {
const routers = formatter(RouterConfig[1].routes);
const testAll = index =>
new Promise(async reslove => {
await testPage(routers[index]);
if (index < routers.length - 1) {
const newIndex = index + 1;
await testAll(newIndex);
reslove();
}
reslove();
});
await testAll(0);
const routers = formatter(RouterConfig[1].routes);
routers.forEach(route => {
fit(`test pages ${route}`, testPage(route));
});
});
......@@ -31,7 +31,7 @@ startServer.stdout.on('data', data => {
console.log('Development server is started, ready to run tests.');
const testCmd = spawn(
/^win/.test(process.platform) ? 'npm.cmd' : 'npm',
['test', '--', '--maxWorkers=1'],
['test', '--', '--maxWorkers=1', '--runInBand'],
{
stdio: 'inherit',
}
......
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