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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mock route for ppt #4262

Merged
merged 1 commit into from
Mar 18, 2024
Merged

feat: mock route for ppt #4262

merged 1 commit into from
Mar 18, 2024

Conversation

kobenguyent
Copy link
Collaborator

@kobenguyent kobenguyent commented Mar 18, 2024

Motivation/Description of the PR

Network requests & responses can be mocked and modified. Use mockRoute which strictly follows Puppeteer's setRequestInterception API.

I.mockRoute('https://reqres.in/api/comments/1', request => {
  request.respond({
    status: 200,
    headers: { 'Access-Control-Allow-Origin': '*' },
    contentType: 'application/json',
    body: '{"name": "this was mocked" }',
  });
})
I.mockRoute('**/*.{png,jpg,jpeg}', route => route.abort());

// To disable mocking for a route call `stopMockingRoute`
// for previously mocked URL
I.stopMockingRoute('**/*.{png,jpg,jpeg}'

To master request intercepting use HTTPRequest object object passed into mock request handler.

Applicable helpers:

  • Puppeteer

Type of change

  • 馃殌 New functionality
  • 馃搵 Documentation changes/updates

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@DavertMik
Copy link
Contributor

@kobenguyent Nice! We can finally drop all mentions of mock-helper and PollyJS

@kobenguyent kobenguyent merged commit 74a73e0 into 3.x Mar 18, 2024
12 of 13 checks passed
@kobenguyent kobenguyent deleted the feat-mock-route-ppt branch March 18, 2024 12:15
@kobenguyent kobenguyent mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] - implementing the request interception for ppt helper MockRequest with Puppeteer not working
2 participants