Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a reason to add a blank line after a given? #15

Closed
murdos opened this issue Dec 17, 2023 · 5 comments · Fixed by #16
Closed

Is there a reason to add a blank line after a given? #15

murdos opened this issue Dec 17, 2023 · 5 comments · Fixed by #16

Comments

@murdos
Copy link

murdos commented Dec 17, 2023

I was going to apply this plugin to my projects (thanks BTW!), until I noticed that blank lines were added systematically after given phrases, which lead to a strange formatting: why make a separate block for given, but not separate when and then blocks?

Before

  Scenario: Should not add beer as user
    Given I am logged in as "user"
    When I add beer to catalog
      | Name       | Cloak of feathers |
      | Unit price | 8.53              |
    Then I should be forbidden

After

  Scenario: Should not add beer as user
    Given I am logged in as "user"

    When I add beer to catalog
      | Name       | Cloak of feathers |
      | Unit price | 8.53              |
    Then I should be forbidden
@jdeniau
Copy link
Member

jdeniau commented Dec 17, 2023

Hi,

Yes I did that on purpose in order to separate the "fixtures" bloc and the real test bloc.

In your case you do have only one given, but you can have something like that :

Given xxx
And yyy
And zzz

When I do aaa
Then bbb
And ccc

I think it does improve the readability of the test file.

@murdos
Copy link
Author

murdos commented Dec 19, 2023

Do you think that it could it could be turned off with a configuration parameter?
I understand your POV, but this is still quite unusual and controversial :)

@jdeniau
Copy link
Member

jdeniau commented Dec 20, 2023

It might be yes. I will think about it but it may also become the default value :

It you have more than one line break, it would remove extra line break to be only one.
If you do not have line break, then the plug-in would keep "as-it" unless you configure the option lineBreakAfterContext to "force" or something like that. In this case, it will force a line break (as it does now).

@jdeniau
Copy link
Member

jdeniau commented Dec 28, 2023

@murdos this has been released as the default value in version 2.2.1 (2.2.0 + two small fixes when I tested on our stack)

See https://github.com/mapado/prettier-plugin-gherkin/blob/b7ccd8e3634d96e5cc79d82c651f040836c07be5/README.md#forcenewlinebetweenstepblocks-default-false

@murdos
Copy link
Author

murdos commented Dec 28, 2023

@jdeniau: thanks! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants