Search code examples
javascriptjestjsstenciljs

Stencil.js newE2EPage Styles


How can we set global styles for Stencil.js newE2EPage.

newE2EPage seems to have a addStyleTag method. Is this a method we can use to set styles and if so how?


Solution

  • Yes, you can use page.addStyleTag which actually comes from puppeteer (see https://pptr.dev/#?product=Puppeteer&version=master&show=api-pageaddstyletagoptions).

    describe('Some Page', () => {
      let page: E2EPage;
    
      beforeEach(async () => {
        page = await newE2EPage({ html: '<my-comp />' });
        await page.addStyleUrl('/build/app.css'); // replace "app" with your namespace
      });
    });