😎 A demonstration repository explains how to replace from Karma to Puppeteer.
Run npm test
to execute the unit tests via Karma Puppeteer.
And captures screenshot viewport after each spec. The captured images are here(by reg-suit).
In summary, I did:
- Create a webpack-dev-middleware instance using angualr-cli's karma plugin.
- Boot an Express server using thi middleware
- This app serves a custom context HTML file(test/context.html) while referring https://github.com/jasmine/jasmine#installation.
- Expose Puppeteer's
screenshot
function and use it viaafterEach
. - Let the Puppeteer's page object go to the html file served by the Express app.
If you want more details, please see puppeteer-test.js.