Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: www output target is not needed #42

Open
3 tasks done
pfteter opened this issue Jun 13, 2024 · 0 comments
Open
3 tasks done

bug: www output target is not needed #42

pfteter opened this issue Jun 13, 2024 · 0 comments
Labels

Comments

@pfteter
Copy link

pfteter commented Jun 13, 2024

Prerequisites

Stencil Playwright Version

0.2.0

Current Behavior

According to the doumentation a www output is needed / eventually full build to run PW-Stencil.
On big projects with file scanning antivirus tools this leads to a huge preformance drop - up to few minutes.

Expected Behavior

  • No stencil build is needed to run it - just reference to dist folder - this can be avoided with customizing command
  • www output is not needed but it is per documentation

Steps to Reproduce

run the project

Code Reproduction URL

https://no-url

Additional Information

Here is a small PoC that directly consumes dist without having to run stencil / page routes

import {test as base, expect} from '@playwright/test';

const extendedHtml = html => `
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Stencil Playwright Test</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="http://localhost:3333/library.css" />
    <script type="module" src="http://localhost:3333/library.esm.js"></script>
    <script nomodule src="http://localhost:3333/library.js"></script>
  </head>
  <body>
  ${html}
  </body>
</html>`;

// even better to add a render extension/fixture to test, have to check
export const test = base.extend({
  page: async ({page}, use: (r) => Promise<void>) => {
    page['render'] = async (html: string, options?) => {
      await page.setContent(extendedHtml(html), options);
      await expect(page.locator('.library-hydrated')).toBeVisible();

      const container = page.locator('body > *').first();
      await expect(container).toBeVisible();
      return {container};
    };

    await use(page);
  },
});

playwright.config.ts

....
  webServer: {
    command: 'npx http-server -s -p 3333 -a localhost ./dist/library',
    url: 'http://localhost:3333/library.esm.js',
  },

Sample test:

test('Button test', async ({page}) => {
  const {container} = await page.render(`
    <button color="primary">Save</button>
  `);

await expect(container).toBeVisible();

with renderer fixture it can be

test('Button test', async ({render}) => {
    render(`<...html>`)
}```
@ionitron-bot ionitron-bot bot added the triage label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant