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

Option for lowercase-name rule to allow uppercase for top level describes #247

Closed
overlookmotel opened this issue Apr 23, 2019 · 6 comments · Fixed by #611
Closed

Option for lowercase-name rule to allow uppercase for top level describes #247

overlookmotel opened this issue Apr 23, 2019 · 6 comments · Fixed by #611

Comments

@overlookmotel
Copy link

My preferred style is for top-level describe/its to have names starting with a capital letter, and all nested blocks lower case. So then the concatenated test name reads like a sentence starting with a capital letter.

e.g.:

describe('Monkeys', () => {
  describe('eat', () => {
    it('bananas', () => { /* ... */ } );
  });

  it('sleep in the daytime', () => { /* ... */ } );
});

it('Elephants are very big', () => { /* ... */ } );

// Monkeys eat bananas
// Monkeys sleep in the daytime
// Elephants are very big

At present this style is not possible to enforce with the lowercase-name rule.

How about:

  1. Add lowercase-name ignore options 'top-describe', 'top-it', 'top-test' (and 'top' as a shortcut for all three)
  2. Add a new uppercase-name rule with the same options.

Alternatively, a new rule called e.g. name-case could cover all possible permutations, with options something like:

"lower"
"upper"

// Override for different statements
"lower", { "describe": "upper", "it": "upper", "test": "upper" }
"upper", { "describe": "ignore" }

// Override for all top-level statements
"lower", { "top": "upper" }

// Override for specific top-level statements
"lower", { "describe": "upper", "top": { "describe": "lower" } }

Do you feel this would be useful?

@SimenB
Copy link
Member

SimenB commented Apr 24, 2019

Happy to merge a PR with an ignore option added 🙂

@overlookmotel
Copy link
Author

Great! What do you think about a new name-case rule which covers all possibilities?

@gayathrigs27
Copy link

I will take this up

@overlookmotel
Copy link
Author

@gayathrigs27 Great!

Which variant are you planning to implement? My favoured one was a name-case rule as that covers all possibilities. I'm not sure if the maintainers would accept that though.

@gayathrigs27
Copy link

I thought of using the approach SimenB suggested

github-actions bot pushed a commit that referenced this issue Jun 23, 2020
# [23.17.0](v23.16.0...v23.17.0) (2020-06-23)

### Features

* **lowercase-name:** support `ignoreTopLevelDescribe` option ([#611](#611)) ([36fdcc5](36fdcc5)), closes [#247](#247)
@github-actions
Copy link

🎉 This issue has been resolved in version 23.17.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