codeceptjs / codeceptjs/CodeceptJS

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

Đang mở
#2,517 0 bình luận 7 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
4.2k
Fork
757
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
16

Mô tả

#### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.