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

feat(rules): Add no-empty-title rule #238

Merged
merged 17 commits into from Mar 15, 2019
Merged

feat(rules): Add no-empty-title rule #238

merged 17 commits into from Mar 15, 2019

Conversation

himynameisdave
Copy link
Contributor

@himynameisdave himynameisdave commented Mar 10, 2019

Having an empty string as title is pretty useless. This adds a new rule to ensure that tests have real titles.

Resolves #226


The following patterns are considered warnings:

describe('', () => {});
describe('foo', () => {
  it('', () => {});
});
it('', () => {});
test('', () => {});
xdescribe('', () => {});
xit('', () => {});
xtest('', () => {});

These patterns would not be considered warnings:

describe('foo', () => {});
describe('foo', () => {
  it('bar', () => {});
});
test('foo', () => {});
it('foo', () => {});
xdescribe('foo', () => {});
xit('foo', () => {});
xtest('foo', () => {});

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add it to the main readme? (Prettier handles the formatting in the table)

Also, CI is unhappy since we don't have 100% test coverage. Either add the test cases or delete the code if it doesn't actually do anything :)

@himynameisdave
Copy link
Contributor Author

@SimenB yes I can add to the README, and yes I can get us to 100% coverage!

@himynameisdave
Copy link
Contributor Author

@SimenB resolved your comments.

Note the build is still failing, but it is also failing on master.

Let me know when that gets resolved upstream and I'll merge that fix in here. Otherwise just let me know if you have any other comments to address! 👍

README.md Outdated Show resolved Hide resolved
@SimenB
Copy link
Member

SimenB commented Mar 12, 2019

master is fixed, so a rebase/merge should do the trick 🙂

@himynameisdave
Copy link
Contributor Author

@SimenB resolved the typo, let me know if I need to fix anything else!

@SimenB
Copy link
Member

SimenB commented Mar 13, 2019

Added a test for template literals - if CI is happy then I'm happy 🙂

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a failing test, could you fix it?

@himynameisdave
Copy link
Contributor Author

@SimenB yeah it wasn't handling template literals well.

These cases weren't reporting:

it(``, () => {});
it(`${someVar}`, () => {});

They are now though, so everything should work! Let me know if you need to me change anything else!

@@ -218,6 +218,7 @@ module.exports = {
getStringValue,
isDescribe,
isFunction,
isTemplateLiteral,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops my bad!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SimenB SimenB merged commit c793b7a into jest-community:master Mar 15, 2019
@himynameisdave himynameisdave deleted the issues/226 branch March 15, 2019 16:30
@SimenB
Copy link
Member

SimenB commented Mar 15, 2019

🎉 This PR is included in version 22.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@garyking
Copy link
Contributor

The rule doesn't seem to work. It needs to be added to index.js right?

@SimenB
Copy link
Member

SimenB commented Mar 15, 2019

Good point!

@himynameisdave
Copy link
Contributor Author

Oops my bad!

@SimenB
Copy link
Member

SimenB commented Mar 15, 2019

Fixed in 22.4.1, thanks for reporting @garyking!

@iamnewton
Copy link

Was this rule removed at some point? I don't see it in the docs, nor in the file system and I'm not seeing reference to its removal.

@SimenB
Copy link
Member

SimenB commented Apr 21, 2020

Merged into valid-title in bb2d09e

@iamnewton
Copy link

Thanks @SimenB

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

Successfully merging this pull request may close these issues.

New rule request: no-empty-title
4 participants