diff --git a/package.json b/package.json index eddfd95cea0b57a54c9d42e396ece88938edc1ef..2e3a1a801d3314dd871389c6eb35a71ec7857b5f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "dva": "^2.4.0", "enquire-js": "^0.2.1", "hash.js": "^1.1.5", - "jest-puppeteer": "^3.5.1", "lodash": "^4.17.10", "lodash-decorators": "^6.0.0", "memoize-one": "^4.0.0", @@ -57,7 +56,7 @@ "react-router-dom": "^4.3.1" }, "devDependencies": { - "@types/react": "^16.4.16", + "@types/react": "^16.7.6", "@types/react-dom": "^16.0.9", "antd-pro-merge-less": "^0.2.0", "antd-theme-webpack-plugin": "^1.1.8", @@ -76,6 +75,7 @@ "eslint-plugin-react": "^7.11.1", "gh-pages": "^2.0.1", "husky": "^1.1.2", + "jest-puppeteer": "^3.5.1", "lint-staged": "^8.0.4", "merge-umi-mock-data": "^0.0.3", "mockjs": "^1.0.1-beta3", diff --git a/src/e2e/baseLayout.e2e.js b/src/e2e/baseLayout.e2e.js index 8487a758fe0131cf8439f574ee5e79022b6ca3d5..9357466149550b6a4d75b0574f01041f041be3a5 100644 --- a/src/e2e/baseLayout.e2e.js +++ b/src/e2e/baseLayout.e2e.js @@ -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)); }); }); diff --git a/tests/run-tests.js b/tests/run-tests.js index 0a06235224b0d65a74fa11c7a5a3526c565e1837..2fc00c162b62ee0da98d2ba24826a960a756235f 100644 --- a/tests/run-tests.js +++ b/tests/run-tests.js @@ -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', }