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

Issue with puppeteer for mocking network requests #2326

Open
efattal opened this issue Apr 3, 2020 · 5 comments · Fixed by #2330
Open

Issue with puppeteer for mocking network requests #2326

efattal opened this issue Apr 3, 2020 · 5 comments · Fixed by #2330
Assignees
Labels
Resolution: Needs Investigation This PR or Issue should be investigated from the Stencil team

Comments

@efattal
Copy link

efattal commented Apr 3, 2020

Stencil version:

 @stencil/core@ 1.12.1 (actually all versions after 1.8.11)

I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
Mocking networks requests with page.setRequestInterception(true) doesn't work anymore while it worked with @stencil/core 1.8.11.

Error:

Request is already handled!

      12 |     page.on('request', function(req: Request) {
      13 |       if (req.method() == 'GET' && req.url().endsWith('/api/v1/employees')) {
    > 14 |         req.respond({
         |             ^
      15 |           status: 200,
      16 |           contentType: 'application/json',
      17 |           body: JSON.stringify({

      at assert (node_modules/puppeteer/lib/helper.js:270:11)
      at Request.respond (node_modules/puppeteer/lib/NetworkManager.js:462:5)
      at Request.<anonymous> (node_modules/puppeteer/lib/helper.js:112:23)
      at Page.<anonymous> (src/components/my-component/my-component.e2e.ts:14:13)
      at NetworkManager.<anonymous> (node_modules/puppeteer/lib/Page.js:110:68)
      at NetworkManager._onRequest (node_modules/puppeteer/lib/NetworkManager.js:240:10)
      at NetworkManager._onRequestPaused (node_modules/puppeteer/lib/NetworkManager.js:216:12)
        -- ASYNC --
      at Request.<anonymous> (node_modules/puppeteer/lib/helper.js:111:15)
      at Page.<anonymous> (src/components/my-component/my-component.e2e.ts:14:13)
      at NetworkManager.<anonymous> (node_modules/puppeteer/lib/Page.js:110:68)
      at NetworkManager._onRequest (node_modules/puppeteer/lib/NetworkManager.js:240:10)
      at NetworkManager._onRequestPaused (node_modules/puppeteer/lib/NetworkManager.js:216:12)
      at CDPSession._onMessage (node_modules/puppeteer/lib/Connection.js:200:12)
      at Connection._onMessage (node_modules/puppeteer/lib/Connection.js:112:17)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 4 passed, 5 total
Snapshots:   0 total
Time:        11.445s
Ran all test suites.

Expected behavior:
Should work as it used to.

Steps to reproduce:
See this Github repo for a simple example. Switch to @stencil/core 1.8.11 and it will work.

Related code:

// insert any relevant code here

Other information:

@ionitron-bot ionitron-bot bot added the triage label Apr 3, 2020
@splitinfinities
Copy link
Contributor

splitinfinities commented Apr 3, 2020

Seconded. We started writing tests for our app and it seems we can't hijack request url's like I expected, using the same methodology above.

@StevenMeyer
Copy link

This was "fixed" and then reverted 5 days later. Any plans to fix it @manucorporat ?

@dsappet
Copy link

dsappet commented Sep 13, 2021

Ran into this today. Any update from the Ionic team?

@splitinfinities
Copy link
Contributor

I'm going to dig deeper into why this got reverted and report back to everyone.

@splitinfinities splitinfinities self-assigned this Sep 14, 2021
@splitinfinities splitinfinities added Feature: Testing Resolution: Needs Investigation This PR or Issue should be investigated from the Stencil team labels Sep 14, 2021
@ionitron-bot ionitron-bot bot removed the triage label Sep 14, 2021
@BHuber-PlanB
Copy link

@splitinfinities Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Needs Investigation This PR or Issue should be investigated from the Stencil team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants