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

test.todo should allow and ignore implementation function #10100

Closed
samgladstone opened this issue May 29, 2020 · 5 comments
Closed

test.todo should allow and ignore implementation function #10100

samgladstone opened this issue May 29, 2020 · 5 comments

Comments

@samgladstone
Copy link

🚀 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.

@jeysal
Copy link
Contributor

jeysal commented May 29, 2020

I've also thought about this a couple of times when todo screamed at me for providing a second argument, but then again I personally believe it's worth it to avoid the possibility of forgetting to change test.todo to test after writing it out, being happy that the test run passes, and shipping the code. If you have some WIP code to store, in a comment below it'll be way more obvious that it's not being run yet.

@samgladstone
Copy link
Author

samgladstone commented 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.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@SimenB
Copy link
Member

SimenB commented Feb 26, 2022

@samgladstone I think that use case is better covered by a test.failing or something (https://github.com/avajs/ava/blob/main/docs/01-writing-tests.md#failing-tests).

If you're interested, please write up a feature request for that - I think the current behaviour of todo should remain as is

@SimenB SimenB closed this as completed Feb 26, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants