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.

[jest/valid-title] false negatives then passing a string variable instead of inlining string directly

See original GitHub issue

mini example:

import { getEstimateBudgetAndTotal } from './shared'

// eslint-disable-next-line jest/valid-title
describe(getEstimateBudgetAndTotal.name, () => {
  it('returns zero if passed no data', () => {
    expect(getEstimateBudgetAndTotal()).toMatchInlineSnapshot(`
      Object {
        "totalBudget": 0,
        "totalEstimate": 0,
        "totalPaid": 0,
      }
    `)
  })
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
G-Rathcommented, Sep 11, 2021

I’ve thought about using type information to improve this rule, but realised this boils down to wanting to enforce either:

  1. consistent use of literal strings only as titles (aka disallowing passing in non-literal strings or literal numbers)
  2. ensure that the correct type is always being passed as titles (which is number | string | Function | FunctionLike)

The first is exactly what a linting rule is good for and what this rule can do; The second is exactly what TypeScript is for and do a lot better than a linting rule.

Now yes we could use type information to extend this rule to allow it to enforce 2. but that would require TypeScript to be available meaning you might as well just rely on TypeScript instead to handle this as it’s going to be much better at enforcing this.

So I think the solution here is that you should be using ignoreTypeOfDescribeName to have this rule not try and check the type at all.

0reactions
JustFly1984commented, Sep 13, 2021

@G-Rath Thanx!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit test pass string argument any string value except null or ...
What are you trying to test? If the test is not checking the guard then pass an expected string value
Read more >
C++ - Inline Variables and Functions - Pablo Arias
Inlining means suppressing a call to a function by copying the function's instructions directly into the caller's body. In other words, ...
Read more >
Matching fuzzy string variables - Statalist
My goal is to go through the successfully merged individuals and check for any false negatives based on there name.
Read more >
Optimization Report - Pascal Analyzer
The reason is that initialization-finalization of the variable has to be done for each loop iteration. Managed variables are strings, interfaces, dynamic arrays ......
Read more >
Secrets of the Glasgow Haskell Compiler inliner - Microsoft
good compiler must inline many of these calls to recover an efficiently executable program. ... In GHC, a variable's name is actually a...
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