You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #558 discussions, we've noticed that the test files across the codebase have a mix of declarative and imperative style.
What happened: When contributing for the first time, I didn't know what style to follow while coding the tests since it's mixed across the codebase and there's tool/docs mention to enforce it
The following code is from __tests__/paste.js
// declarativetest('should paste text in textarea',()=>{ ... }// imperativetest('does not paste when readOnly',()=>{ ... }
Reproduction repository: Go through the tests file of the codebase and see a mixture of declarative and imperative styles.
Problem description: Contributors should know whether style to choose, the current situations may cause a lot of confusion and PR discussions
Suggested solution: Discuss in this issue the following topics:
What would be the best test style for this codebase: Declarative or Imperative?
How to enforce a test style?
The text was updated successfully, but these errors were encountered:
LauraBeatris
changed the title
style: use consistent test style across codebase
Use consistent test style across codebase
Feb 19, 2021
After thinking about this both these styles seem good to me - whatever is shorter/more descriptive for the test being written:
test('paste text in textarea')test('xyz does foo if bar')
Sometimes even a short abstract declaration without any verb might give a better impression what the test is about.
The longer I think about this, the harder I find it to state a preference.
But one other thing becomes clearer:
The modal verb should just adds noise. Of course it should - that's why we're testing it.
When repeated all over again just to stick to this style, it sometimes also causes unnecessarily long and awkward test descriptions that add little to no value to the test code.
So maybe an eslint-rule just warning about modal verbs in test descriptions would be the way to go.
In #558 discussions, we've noticed that the test files across the codebase have a mix of declarative and imperative style.
What happened: When contributing for the first time, I didn't know what style to follow while coding the tests since it's mixed across the codebase and there's tool/docs mention to enforce it
The following code is from
__tests__/paste.js
Reproduction repository: Go through the tests file of the codebase and see a mixture of declarative and imperative styles.
Problem description: Contributors should know whether style to choose, the current situations may cause a lot of confusion and PR discussions
Suggested solution: Discuss in this issue the following topics:
The text was updated successfully, but these errors were encountered: