小编A. *_*ich的帖子

赛普拉斯看不到自定义 cy。命令

赛普拉斯无法导入自定义命令

命令.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 文件为空。

typescript cypress

10
推荐指数
4
解决办法
1万
查看次数

如果在 Cypress docker 容器中运行,Cypress 会中止 XHR 请求

我正在使用 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。

gitlab gitlab-ci cypress

5
推荐指数
1
解决办法
1497
查看次数

标签 统计

cypress ×2

gitlab ×1

gitlab-ci ×1

typescript ×1