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

Filter resource type #11

Open
wallynm opened this issue Sep 13, 2019 · 1 comment
Open

Filter resource type #11

wallynm opened this issue Sep 13, 2019 · 1 comment

Comments

@wallynm
Copy link
Contributor

wallynm commented Sep 13, 2019

Instead of control just one ressourceType it's better to control what each configuration/setup needs, in my case i need to mock document, xhr and other things but i don't need scripts files or styles because once they're cached by the Mockeer, i can't certify that my application it's broken because i'm testing it against a cached JS version.

So to avoid that an filter based into ressourceType listed into Puppteer docs as we can find here:
https://pptr.dev/#?product=Puppeteer&version=v1.20.0&show=api-requestresourcetype

You configure what ressourceTypes you wanna to blacklist using

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await mockeer(browser, {
    disallowedResourceTypes: ['image', 'script', 'stylesheet']
  });
  await page.goto('https://www.example.com');
  await page.close();
  await browser.close();
})();

default values as [] empty array so doesn't change anything of the current API that's been used into other projects.

My fixtures sizes was something like 5mb and with this update - allowing you to choose what you be mocking it's down to 50kb each fixture as DO need my CSS files and JS files updated every time through tests.

@wallynm
Copy link
Contributor Author

wallynm commented Sep 13, 2019

Another approach that we can discuss it's an allowedResourceTypes which do include what you wanna record.

Same result, different approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant