Search code examples
reactjstypescriptcypresse2e-testingtsconfig

cy.pa11y typescript error: Property 'pa11y' does not exist on type 'cy & CyEventEmitter'.ts(2339)


I am using Cypress 10.4.0 and I am using Typescript. The test is running fine, but my editor VSCode in this case has a ts error as the image below:

ts(2339) error

Any ideas how to fix it? Here is my tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "baseUrl": "../node_modules",
    "target": "es5",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "lib": ["es5", "dom"],
    "jsx": "react",
    "types": ["cypress", "@testing-library/cypress"],
    "paths": {
      "@cypress/*": ["../cypress/support/*"],
      "@interceptors/*": ["../cypress/interceptors/*"],
      "@fixtures/*": ["../cypress/fixtures/*"]
    }
  },
  "include": ["**/*.ts"]
}

Solution

  • Just include cypress-audit in the tsconfig-json:

    {
      "compilerOptions": {
        "strict": true,
        "baseUrl": "../node_modules",
        "target": "es5",
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "lib": ["es5", "dom"],
        "jsx": "react",
        "types": ["cypress", "@testing-library/cypress"],
        "paths": {
          "@cypress/*": ["../cypress/support/*"],
          "@interceptors/*": ["../cypress/interceptors/*"],
          "@fixtures/*": ["../cypress/fixtures/*"]
        }
      },
      "include": ["./**/*.ts", "../node_modules/cypress-audit"] // This was missing.
    }