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.

test.todo should allow and ignore implementation function

See original GitHub issue

🚀 Feature Proposal

I was hoping to reopen the discussion about whether test.todo should ignore a passed in function for the second parameter rather than throwing an error.

This was discussed in original issue, but it seemed to peter out.

Motivation

I see two reasons why this could be helpful:

  1. For stubbing tests (see the original issue)
  2. The test cannot be finalised for some reason

Example

test.todo('This is a test', () => {
  // something to come back to...
});

Pitch

This is an extension existing functionality.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
samgladstonecommented, May 29, 2020

I’m currently in the position where I want to test something that partly depends on the implementation of another package. However, the other package has some inconsistencies that are meaning its hard to write the test.

I don’t want to throw away what I have written, as intend to keep an eye on it to come back to at some point.

The alternatives that I see are to use:

test.skip

I would prefer that my code skips 0 tests by default. I often work by temporarily adding test.only or test.skip to see how things are going. But, I don’t want to leave any of these in the code by accident. So I think it’s reasonable to prefer to have 0 .skips and some .todos checked in.

Wrap it in a describe

So the next best alternative, at least IMO, is to wrap the todo in a describe block:

describe('todo: This is the test description', () => {
  test.todo('Do this');

  const implementation = () => {

 }
});

It’s okay, but I think it’s cleaner to just put it in the todo?


@jeysal, I see what you are saying, I guess I am coming it from the other way round! I realised I missed one only that I missed and I didn’t catch it because of the skips I had.

0reactions
github-actions[bot]commented, Mar 29, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use test.todo() in Jest | heyfirst.co - First Sutham
Problem. Let's say, we have a Add to wishlist button component that will be disable if user is not logged in yet, and...
Read more >
Using Jest's todo feature - Stack Overflow
For example, I want to sketch out tests in my subscriptions.test.ts file so I create the following: describe('Subscription Tests', () => { ...
Read more >
Globals - Jest
Runs a function after all the tests in this file have completed. If the function returns a promise or is a generator, Jest...
Read more >
7. Incomplete and Skipped Tests — PHPUnit 9.5 Manual
This misinterpretation leads to the test reports being useless – you cannot see whether a test is actually successful or just not yet...
Read more >
Jest Testing like a Pro - Tips and tricks
Tests should not rely on external apis/services, they should not rely on globals or other objects that are persisted across different tests, so ......
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