codeceptjs / codeceptjs/CodeceptJS

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

Ouverte
#2,517 0 commentaires 7 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
4.2k
Forks
757
Merge moyen
2 j 9 h
PR mergées (30 j)
16

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.