赛普拉斯:commands.ts 下的导入行导致错误
Cypress: Import line under commands.ts causes errors
当我将导入添加到 commands.ts
时,运行 测试出现错误。
commands.ts
import 'cypress-localstorage-commands';
/* eslint-disable */
declare namespace Cypress {
interface Chainable<Subject = any> {
commandA();
commandB();
commandC();
}
}
错误:
Module not found: Error: Can't resolve 'cypress-localstorage-commands'
in 'C:...\cypress\support\commands\commands' resolve
'cypress-localstorage-commands' in 'C:...\cypress\support\commands'
Parsed request is a module using description file:
C:...\angular\package.json (relative path:
./cypress/support/commands)
Field 'browser' doesn't contain a valid alias configuration
我的导入错误的解决方案是将 'global' 添加到 commands.ts。
import cypress-localstorage-commands';
/* eslint-disable */
declare global{
namespace Cypress {
interface Chainable<Subject = any> {
commandA();
commandB();
commandC();
}
}
}
当我将导入添加到 commands.ts
时,运行 测试出现错误。
commands.ts
import 'cypress-localstorage-commands';
/* eslint-disable */
declare namespace Cypress {
interface Chainable<Subject = any> {
commandA();
commandB();
commandC();
}
}
错误:
Module not found: Error: Can't resolve 'cypress-localstorage-commands' in 'C:...\cypress\support\commands\commands' resolve 'cypress-localstorage-commands' in 'C:...\cypress\support\commands'
Parsed request is a module using description file: C:...\angular\package.json (relative path: ./cypress/support/commands) Field 'browser' doesn't contain a valid alias configuration
我的导入错误的解决方案是将 'global' 添加到 commands.ts。
import cypress-localstorage-commands';
/* eslint-disable */
declare global{
namespace Cypress {
interface Chainable<Subject = any> {
commandA();
commandB();
commandC();
}
}
}