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

[new rule] strict formatting for describe and test blocks #113

Closed
eddiesholl opened this issue May 23, 2018 · 5 comments · Fixed by #1563
Closed

[new rule] strict formatting for describe and test blocks #113

eddiesholl opened this issue May 23, 2018 · 5 comments · Fixed by #1563

Comments

@eddiesholl
Copy link

We would really like to enforce some strict formatting for the various parts of jest test syntax. I'm not sure if these would be general enough to be considered useful, but they seem like a nice way to help ensure test code is nicely structured. An example of my teams desired syntax is:

describe('some tests', () => {
  let varName

  beforeEach(() => {
    let varName = 'foo'
  })

  it('does something cool', () => {
    const result = callAFuncWith(varName)
    result.wow()

    expect(result).toBeAwesome()
  })
})

Seperate rules could enforce:

  • a blank line after describe level lets
  • a blank line after a beforeEach
  • a blank line between an expect and test setup statements

Another option would be a new 'eslint-jest-formatting' package.

@SimenB
Copy link
Member

SimenB commented May 23, 2018

We landed on not including any formatting rules in #17. Then again, I don't really mind them - they don't really hurt. And personally I really like organising tests into a when-given-then format, so I'd like rules like that.

Soooooo, PR welcome? :D

@thymikee holler if you disagree

@thymikee
Copy link
Member

As long as it's not a default, I'm on board ;)

@SimenB
Copy link
Member

SimenB commented May 23, 2018

Yeah, agreed. Should not be part of recommended

@SimenB
Copy link
Member

SimenB commented May 5, 2019

Copy link

github-actions bot commented Aug 7, 2024

🎉 This issue has been resolved in version 28.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants