codeceptjs / codeceptjs/CodeceptJS

Gherkin steps without helper methods do not print to output/reports because they do not emit step events

未关闭
#2,517 0 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
4.2k
派生
757
平均合并
2 天 9 小时
30 天内合并 PR
16

描述

#### What are you trying to achieve?
Fire an event for gherkin steps that do not include any helper method

#### What do you get instead?
Steps without any helper method do not emit step `start/finish/pass/fail`
Because of this when you run your feature, the steps without helper methods do not get printed to the console using `--steps` or reports

I think this is a common practice to setup data in some Givens and then perform and action on it. It would be nice if they emitted an event like all other steps do

> Provide test source code if related

Steps setting up data
```js
Given('a request path {string}', (requestPath) => {
request.url = requestPath;
});

Given('a request payload', (requestPayload) => {
request.payload = requestPayload;
});

When('the request is sent as {string}', async (verb) => {
if (verb === 'POST') request.response = await I.sendPostRequest(request.url, request.payload);
});
```

Scenario
```
@Test
Scenario: Test Scenario
Given a request path "https://jsonplaceholder.typicode.com/posts"
And a request payload
"""
{
"title": "foo",
"body": "bar",
"userId": "1"
}
"""
When the request is sent as "POST"
```

Output
```bash
[1] Starting recording promises
Emitted | suite.before ([object Object])
Test Scenario @Test
Emitted | test.before ([object Object])
Emitted | test.start ([object Object])
Emitted | step.before (I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\…
Emitted | step.after (I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\"…
Emitted | step.start (I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\"…
When the request is sent as "POST"
I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\",\n \"body\": \"bar…
› [Request] {"baseURL":"https://jsonplaceholder.typicode.com/posts","method":"POST","data":{"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\",\n \"body\": \"bar\",\n \"userId\": \"1\"\n}"}
› [Response] {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\",\n \"body\": \"bar\",\n \"userId\": \"1\"\n}","id":101}
Emitted | step.passed (I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\…
Emitted | step.finish (I send post request "https://jsonplaceholder.typicode.com/posts", {"type":"DocString","location":{"line":78,"column":5},"content":"{\n \"title\": \"foo\…
Emitted | test.passed ([object Object])
Emitted | test.finish ([object Object])
✔ OK in 377ms

Emitted | test.after ([object Object])
Emitted | suite.after ([object Object])

OK | 1 passed // 385ms
Emitted | global.result ([object Object])
Emitted | global.after ([object Object])
```
As you can see only `When the request is sent as "POST"` step emits an event because it has Rest helper method in it

### Details

* CodeceptJS version: 2.6.7
* NodeJS Version: v12.16.0
* Operating System: OSX
* puppeteer, rest helper

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。