提交 802930e7 编写于 作者: 陈帅

fix test script

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册