1

当我将导入添加到 中时commands.ts,我会通过运行测试得到错误。

命令.ts

import 'cypress-localstorage-commands';

/* eslint-disable */
declare namespace Cypress {
  interface Chainable<Subject = any> {
     commandA();
     commandB();
     commandC();
  }
}

错误:

未找到模块:错误:无法解析 'C:...\cypress\support\commands\commands' 中的 'cypress-localstorage-commands' 解析 'C:...\cypress' 中的 'cypress-localstorage-commands' \support\commands'
解析的请求是一个使用描述文件的模块:C:...\angular\package.json (relative path: ./cypress/support/commands) 字段 'browser' 不包含有效的别名配置

4

1 回答 1

0

我的导入错误的解决方案是将“全局”添加到 commands.ts。

import cypress-localstorage-commands';
/* eslint-disable */
declare global{
  namespace Cypress {
    interface Chainable<Subject = any> {
       commandA();
       commandB();
       commandC();
    }
  }
}
于 2022-02-18T08:12:04.707 回答