You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use ava-webcomponents to import the file in your AVA test, which then gives you access to the Puppeteer page variable, as well as a util function for awaiting upgrade of a defined web component.
All imports in your web component file will be resolved relative to the nearest package.json file, which uses a simple Express server instance to import your files.
importtestfrom'ava';importwithComponentfrom'ava-webcomponents';test('It should render "Hello AVA!";',withComponent(`${__dirname}/helpers/example.js`),async(t,{ page, utils })=>{awaitutils.waitForUpgrade('x-ava');constcontent=awaitpage.evaluate(()=>{constnode=document.createElement('x-ava');document.body.append(node);returnnode.innerHTML;});t.is(content,'Hello AVA!');});
With the second argument of the withComponent function you can pass options for puppeteer.launch. However there's also a shortcut for debugging Puppeteer by using withComponent.debug which slows down the tests, opens the devtools, and prevents Chromium from being headless.
About
Utility middleware for testing web components in AVA via Puppeteer.