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

Are types for ServerOptions.whitelist correct? #5680

Closed
mspoulsen opened this issue Nov 13, 2019 · 2 comments
Closed

Are types for ServerOptions.whitelist correct? #5680

mspoulsen opened this issue Nov 13, 2019 · 2 comments

Comments

@mspoulsen
Copy link

I am using cypress with typescript. I was looking at the ServerOptions type:

interface ServerOptions {
    delay: number
    method: HttpMethod
    status: number
    headers: object
    response: any
    onRequest(...args: any[]): void
    onResponse(...args: any[]): void
    onAbort(...args: any[]): void
    enable: boolean
    force404: boolean
    urlMatchingOptions: object
    whitelist(xhr: Request): void
    onAnyRequest(route: RouteOptions, proxy: any): void
    onAnyResponse(route: RouteOptions, proxy: any): void
    onAnyAbort(route: RouteOptions, proxy: any): void
  }

More specifically:

whitelist(xhr: Request): void

Is this type correct? I would expect this type to be:

whitelist(xhr: XMLHttpRequest): void

The xhr passed to the callback certainly behaves like an XMLHttpRequest.

@mspoulsen
Copy link
Author

My bad. I made it work:

Cypress.Server.defaults({
  whitelist: (xhr: Request) => {
    const match = "/sockjs-node/info?";

    return xhr.url.indexOf(match) !== -1;
  }
});

@cypress-io cypress-io locked and limited conversation to collaborators Jan 3, 2020
@nalandial
Copy link
Contributor

nalandial commented Dec 2, 2021

For anyone who comes across this: whitelist was renamed to ignore in Cypress 5 to address this: #6642 in PR #7782

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

No branches or pull requests

2 participants