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

Add support for tests without a callback function #7054

Closed
LandonSchropp opened this issue Sep 26, 2018 · 4 comments
Closed

Add support for tests without a callback function #7054

LandonSchropp opened this issue Sep 26, 2018 · 4 comments

Comments

@LandonSchropp
Copy link

🚀 Feature Proposal

I'd really like to be able to create tests via it without a callback function. These tests should be automatically marked as skipped.

Motivation

When I'm writing a test suite for a complicated object, I like to be able to write all of the tests I want to cover first, and then go back and implement them one by one. This helps me to think about my module at a high level without getting bogged down in the details.

I run Jest in a tab with the --watch flag turned on. It's really handy to be able to write this out first, and then have Jest ticking down the tests I still need to write. I could add skip calls all over the place, but that slows me down when implementing them.

Example

For example, if I were writing a test file for a safelyParseDate function, I might do something like this:

describe("safelyParseDate", () => {

  describe("when the value is an ISO string", () => {
    it("parses the date");
  });

  describe("when the value is not an ISO string", () => {
    it("returns the string unmodified");
  });

  describe("when the value is undefined", () => {
    it("returns undefined");
  });

  describe("when the value is null", () => {
    it("returns null");
  });

  describe("when the value is already a date", () => {
    it("returns the date");
  });
});

Pitch

This behavior is implemented in Mocha, Rspec and other test runners as well. I think it's a good test workflow, and it encourages developers to be thorough and get all of their test cases written down.

@palmerj3
Copy link
Contributor

@LandonSchropp I would follow #6996 since that covers this use-case exactly.

@SimenB
Copy link
Member

SimenB commented Sep 27, 2018

Yeah, this will be covered by #6996, see the issues linked in that PR for discussion about it

@SimenB SimenB closed this as completed Sep 27, 2018
@LandonSchropp
Copy link
Author

Oops, sorry, missed that one. Thanks!

@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 May 12, 2021
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