Skip to content

Can't mock external image request #2108

@zerkalica

Description

@zerkalica

I want to mock all images loading from site, I use mockRequest: I.mockRequest('ANY', 'https://codecept.io/img/*', 200);

But mocking not working for images. Example project: https://github.com/zerkalica/codecept-bug-demo. After npm install ; npm run test i see first page with images. Raw pollyjs npm run test:polly works as i expect.

By default, pollyjs mocks only xhr, fetch requests and it's documentation is not full. I can mock external image request by passing adapterOptions.requestResourceTypes: [ 'xhr', 'fetch', 'image' ] option to pollyjs config. But codecept MockRequest helper doesn't provide option for it.

After #2060 i can pass this option to pollyjs.

But latest npm codeceptjs version is 2.36 without this feature:

this.polly = new PollyJS(title, {
      mode: 'passthrough',
      adapters: ['puppeteer'],
      adapterOptions: {
        puppeteer: { page },
      },
    });

Can you deploy new package version?

PS: I waste some time with this problem. May be add issue about requestResourceTypes and image to codecept/MockRequest documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions