简体   繁体   中英

How to add cypress-plugin-tab to my Angular e2e testing?

I am using Angular12, NX, Cypress & KendoUI. I need to test tabbing through form elements. How do I add cypress-plugin-tab to my e2e testing?

The guide says use require in the suppport/index.ts file - this is not working for me.

I have executed npm install -D cypress-plugin-tab and added require('cypress-plugin-tab') to suppport/index.ts I have added this code to my test:

   let password = 'Password';
   let input = cy.focused();
   
   input.type(username).tab().type(password);

This does not work as it says it cannot find 'tab'. How do I get 'tab' to work in Angular? 在此处输入图像描述

You need to add in tsconfig.json in compilerOptions > types the cypress-plugin-tab src path.

  "compilerOptions": {
    "strict": true,
    "target": "es6",
    "lib": ["es6", "dom"],
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "types": ["node", "cypress", "cypress-plugin-tab/src"],
    "allowSyntheticDefaultImports": true
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM