question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Make title not optional and having two tests with the same title should fail the tests

See original GitHub issue

I’m proposing two breaking changes, that would aim users to have a better test suite (or at least better documented in a way)

Making the title of a test mandatory

I can barely see why there should not be one. I can only imagine the case where the file only has one test in a file whose name is self-explanatory, but even then, an additional title can’t hurt. In all other cases (like having multiple tests without a title), you’re having “undocumented” tests, which is not great for your test suite. I see having a mandatory title as a feature rather than an inconvenience. (And if we do, we should probably forbid "" as the test title).

Having two tests with the same title should fail the tests

  • having two tests in a file (or group, in the future) share the same title should fail the tests
  • (should we implement groups) having two groups in a file or inside another group share the same title should fail the tests

The reasoning is like this: If I have two tests with the same title, I have probably copy-pasted a test without updating the title, or I have two tests that do not describe very well what they are testing. Enforcing different titles for every test should help have more descriptive tests. We already attempt to enforce that in the AVA ESLint plugin, but it would be done more effectively in the runner.

Should the title be kept optional, we would probably ignore tests without title, or accept at most one.

(I made the same proposal in an other test runner, and thought I’d propose it here too. Titles in that test runner are mandatory too by the way)

Let me know what you think 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Jan 26, 2017

I’m a big 👍 on requiring unique test titles. I think that’s a great change.

I would also be ok with requiring a test title for multiple tests, but I kinda like the ability to not have a title when you only have one test though. I use this a lot in my tiny modules. Example. Although, I’m happy to be convinced otherwise.

1reaction
ThomasBemcommented, Jan 25, 2017

I think both of these suggestions are valid and good improvements.

We actually had some trouble with duplicated test titles a while ago. It turned out that when we wrote our first test for a new react component. We always ended up calling it ‘Render to DOM’ by default. None really thought about it and it just happened out of habit.

Then at some point we where making a new component and our ‘Render to DOM’ test just kept on failing. It was a real simple test and we could not figure out what was wrong.

Turned out some other code had broken a previous ‘Render to DOM’ test in a different component and we just didn’t see that it wasn’t the one we where looking at…

Read more comments on GitHub >

github_iconTop Results From Across the Web

REST API Testing Strategy: What Exactly Should You Test?
As in #3. API should fail gracefully. Test cases derived from the table above should cover different test flows according to our needs,...
Read more >
How to Write Test Cases: The Ultimate Guide with Examples
There may be a case where you are testing an application, and someone is making modifications in parallel to the same app, or...
Read more >
What is A/B Testing? A Practical Guide With Examples | VWO
A/B testing (also called split testing) is comparing two versions of a web page to figure out the better performing variation. Learn more...
Read more >
Section 1414 - Individuals with Disabilities Education Act
The agency proposing to conduct an initial evaluation to determine if the child qualifies as a child with a disability as defined in...
Read more >
Test Procedure Manual for Voting Systems - State of Michigan
The preliminary accuracy test should be conducted for both the tabulator and the VAT as soon as the program(s) and ballots are received...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found