codeceptjs / codeceptjs/CodeceptJS

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

Abierto
#2,517 0 comentarios 7 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
4.2k
Forks
757
Merge medio
2 d 9 h
PR fusionados (30 d)
16

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.