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.

suggestion: prefer `test` or `it`

See original GitHub issue

Suggest using test or it (always-test-or-it)

For consistency in code, always use test or always use it.

Rule details

When test is preferred, this rule triggers a warning for any instances of it. When it is preferred, this rule triggers a warning for any instances of test.

This rule is not set by default.

Default configuration

The following pattern is considered warning:

it('example 1', () => {
   expect(files).toHaveLength(1);
});

test('example 2', () => {
   expect(files).toHaveLength(1);
});

The following pattern is not warning when test is set:

test('example 1', () => {
   expect(files).toHaveLength(1);
});

test('example 2', () => {
   expect(files).toHaveLength(1);
});

The following pattern is not warning when it is set:

it('example 1', () => {
   expect(files).toHaveLength(1);
});

it('example 2', () => {
   expect(files).toHaveLength(1);
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Feb 10, 2018

I think 3 options makes sense. Can be an object instead of a single string as well. { fn: 'test', withinDescribe: 'it'} or something

1reaction
macklinucommented, Feb 3, 2018

Should we allow config to differentiate between an it within a describe and by itself at the top level?

I think that could be nice.

When using describe(), I prefer using only it().

describe('myFunction()', () => {
  it('does this thing')
  it('does that thing')
  // etc.
})

When not using describe(), I prefer using only test().

test('does this thing')
test('does that thing')

I’ve worked in codebases that have done one or the other, so being able to configure this could help ensure consistency in those codebases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Suggest & Recommend – English Grammar Lesson
Unlike many verbs, suggest and recommend are not followed by an object + ... recommended that we study this list of vocabulary for...
Read more >
How To Use Recommend, Suggest, Advise [2021] - YouTube
In this video, learn how to use Recommend, Suggest, Advise. Is RECOMMEND ME correct? Is SUGGEST ME correct? Is ADVISE ME correct?
Read more >
How to use SUGGEST & RECOMMEND - YouTube
Even many advanced English students don't know how to use " suggest " and "recommend" properly. In this video I explain the three...
Read more >
Suggest - Grammar - Cambridge Dictionary
We can use the verb suggest with a noun phrase, a that-clause, the -ing form of a verb or a wh-question word (where,...
Read more >
Jest Testing like a Pro - Tips and tricks
... I really suggest you reading it and going back to it every time you write a slightly more complex test or assertion,...
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