赛普拉斯无法导入自定义命令
命令.js
Cypress.Commands.add('generateToken', ({secret}) => {
const totp = require('totp-generator');
const token = totp(secret);
});
Run Code Online (Sandbox Code Playgroud)
支持/index.js
import './commands'
Run Code Online (Sandbox Code Playgroud)
测试规范
/// <reference types="Cypress" />
context('Actions', () => {
beforeEach(() => {})
})
it('Main test', () => {
cy.generateToken('XXXX');
})
Run Code Online (Sandbox Code Playgroud)
在 test.spec.ts 中, generateToken() 一直带有下划线,并且出现错误:
Property 'generateToken' does not exist on type 'cy'.
Run Code Online (Sandbox Code Playgroud)
index.js 和 commands.js 没有从原始目录中移动。cypress.json 文件为空。
我正在使用 cy.route() 进行测试。
这是它在调试中的样子:
1114 [2019-11-19T08:19:31.373Z] ? error (network): Failed to load resource: net::ERR_INSUFFICIENT_RESOURCES
1115 URL: http://localhost:3000/__cypress/xhrs/http://localhost:3000/api/identity/public/pre-login
Run Code Online (Sandbox Code Playgroud)
在我的本地环境中,所有测试都运行正常,但在 gitlab ci 上,我收到了一些请求中止。我使用 Cypress docker 图像,也尝试过 npm docker 图像。
是否有解决此问题的方法?
看起来问题在 4.0 发布后返回。即使使用 nginx。