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

fix test script

上级 f3ec5fa9
...@@ -12,35 +12,23 @@ function formatter(data) { ...@@ -12,35 +12,23 @@ function formatter(data) {
} }
describe('Homepage', async () => { describe('Homepage', async () => {
const testPage = path => const testPage = path => async () => {
new Promise(async reslove => { await page.goto(`${BASE_URL}${path}`);
console.log(`test ${path}`);
await page.goto(`${BASE_URL}${path}`, {
timeout: 600000,
});
await page.waitForSelector('footer', { await page.waitForSelector('footer', {
timeout: 600000, timeout: 2000,
});
reslove();
}); });
const haveFooter = await page.evaluate(
() => document.getElementsByTagName('footer').length > 0
);
expect(haveFooter).toBeTruthy();
};
beforeAll(async () => { beforeAll(async () => {
jest.setTimeout(1000000); jest.setTimeout(1000000);
await page.setCacheEnabled(false); await page.setCacheEnabled(false);
}); });
it(`test pages`, async () => {
const routers = formatter(RouterConfig[1].routes); const routers = formatter(RouterConfig[1].routes);
const testAll = index => routers.forEach(route => {
new Promise(async reslove => { fit(`test pages ${route}`, testPage(route));
await testPage(routers[index]);
if (index < routers.length - 1) {
const newIndex = index + 1;
await testAll(newIndex);
reslove();
}
reslove();
});
await testAll(0);
}); });
}); });
...@@ -31,7 +31,7 @@ startServer.stdout.on('data', data => { ...@@ -31,7 +31,7 @@ startServer.stdout.on('data', data => {
console.log('Development server is started, ready to run tests.'); console.log('Development server is started, ready to run tests.');
const testCmd = spawn( const testCmd = spawn(
/^win/.test(process.platform) ? 'npm.cmd' : 'npm', /^win/.test(process.platform) ? 'npm.cmd' : 'npm',
['test', '--', '--maxWorkers=1'], ['test', '--', '--maxWorkers=1', '--runInBand'],
{ {
stdio: 'inherit', stdio: 'inherit',
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册