typescript - 我的 jest-cucumber 测试无法识别我的步骤定义
问题描述
我正在使用这个库https://www.npmjs.com/package/jest-cucumber以 BDD 格式运行我的 jest 测试。
每当我运行我的示例测试时,我都会得到:
? Given Test for given step
Undefined. Implement with the following snippet:
Given('Test for given step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? When Test for when step
Undefined. Implement with the following snippet:
When('Test for when step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? Then Test for then step
Undefined. Implement with the following snippet:
Then('Test for then step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
Process finished with exit code 1
这是文件所在的文件夹:
我的 BDD 场景:
Feature: E2E Tests
Scenario:Example
Given Test for given step
When Test for when step
Then Test for then step
我的步骤定义代码:
import { loadFeature, defineFeature } from 'jest-cucumber';
const feature = loadFeature('/src/smokeTests/smokeTests.feature');
defineFeature(feature, (test) => {
test('Example', ({ given, when, then }) => {
let x: number;
let z: number;
given('Test for given step', () => {
x = 1;
});
when('Test for when step', () => {
z = x + 3;
});
then('Test for then step', () => {
expect(z).toBe(4);
});
});
});
没有什么其他的想法了!
解决方案
将步骤定义文件重命名为 *.step.ts
推荐阅读
- java - 无法实现 org.eclipse.persistence.internal.libraries.asm.ClassVisitor
- css - 如何在 vuejs 范围样式中使用 ::before 之类的伪选择器
- php - Vimeo App 使用 PHP 从客户端设备直接上传
- ssh - Vault 的 SSH-CA - 仅限于特定目标主机的签名证书
- c++ - c ++导出具有dll代理的特定地址
- typescript - 如何定义具有返回字符串的函数的属性类型?
- html - 当不同行中的colspans(或不同列中的rowspans)是互质数时,html表格的奇怪呈现
- python - 将 csv 写为输出而不是打印
- python - Powershell - 以变量为参数的 JSON 字符串
- angular - 以角度 8 处理 FCM 背景消息