Browse Source

increase timeout

pull/27728/head
shaodahong 4 years ago
parent
commit
4ce36d2680
  1. 1
      .jest.image.js
  2. 1
      docker-compose.yml
  3. 2
      jest-puppeteer.config.js
  4. 24
      tests/shared/imageTest.ts

1
.jest.image.js

@ -20,4 +20,5 @@ module.exports = {
}, },
}, },
preset: 'jest-puppeteer', preset: 'jest-puppeteer',
testTimeout: 10000,
}; };

1
docker-compose.yml

@ -11,6 +11,7 @@ services:
- './jest-stare:/app/jest-stare' - './jest-stare:/app/jest-stare'
- './dist:/app/dist' - './dist:/app/dist'
- '.jest.image.js:/app/.jest.image.js' - '.jest.image.js:/app/.jest.image.js'
- './jest-puppeteer.config.js:/app/jest-puppeteer.config.js'
- './imageSnapshots:/app/imageSnapshots' - './imageSnapshots:/app/imageSnapshots'
- './imageDiffSnapshots:/app/imageDiffSnapshots' - './imageDiffSnapshots:/app/imageDiffSnapshots'
entrypoint: "jest --config .jest.image.js --no-cache -i" entrypoint: "jest --config .jest.image.js --no-cache -i"

2
jest-puppeteer.config.js

@ -10,6 +10,4 @@ module.exports = {
'--disable-dev-shm-usage', '--disable-dev-shm-usage',
], ],
}, },
browser: 'chromium',
browserContext: 'default',
}; };

24
tests/shared/imageTest.ts

@ -16,22 +16,20 @@ expect.extend({ toMatchImageSnapshot });
// eslint-disable-next-line jest/no-export // eslint-disable-next-line jest/no-export
export default function imageTest(component: React.ReactElement) { export default function imageTest(component: React.ReactElement) {
describe(`Image test`, () => { it('component image screenshot should correct', async () => {
it('component image screenshot should correct', async () => { MockDate.set(moment('2016-11-22').valueOf());
MockDate.set(moment('2016-11-22').valueOf()); await page.goto(`file://${process.cwd()}/tests/index.html`);
await page.goto(`file://${process.cwd()}/tests/index.html`); await page.addStyleTag({ path: `${process.cwd()}/dist/antd.css` });
await page.addStyleTag({ path: `${process.cwd()}/dist/antd.css` }); const html = ReactDOMServer.renderToString(component);
const html = ReactDOMServer.renderToString(component); await page.evaluate(innerHTML => {
await page.evaluate(innerHTML => { document.querySelector('#root')!.innerHTML = innerHTML;
document.querySelector('#root')!.innerHTML = innerHTML; }, html);
}, html);
const image = await page.screenshot(); const image = await page.screenshot();
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
MockDate.reset(); MockDate.reset();
});
}); });
} }

Loading…
Cancel
Save