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 摘要。