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

fix test script

parent 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.waitForSelector('footer', {
await page.goto(`${BASE_URL}${path}`, { timeout: 2000,
timeout: 600000,
});
await page.waitForSelector('footer', {
timeout: 600000,
});
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);
}); });
const routers = formatter(RouterConfig[1].routes);
it(`test pages`, async () => { routers.forEach(route => {
const routers = formatter(RouterConfig[1].routes); fit(`test pages ${route}`, testPage(route));
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);
}); });
}); });
...@@ -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% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment