Jest: Feature: test.skip/only/todo aliases

Created on 4 Sep 2016  路  18Comments  路  Source: facebook/jest

Thanks for Jest!

I'm basically looking for the same functionality that AVA has:

There's also a handy test.failing feature. I've never used it, but I can see how it could be valuable!

Enhancement Hi-Pri

Most helpful comment

All 18 comments

Skip is the same as xit / xdescribe, and only is equivalent to fit, AFAIK. You can write a test stub without filling it in, which I guess is equivalent to todo.

Cool, thanks for the info. But what if I prefer the test global over it?

You don't have to use Jasmine, believe it supports swapping out the env to something like TAP if you prefer.

True, but why can't we just add these things? I don't see any harm in doing so... If the test alias is already available, may as well make it behave as expected right?

Increasing the API surface area just because you personally want something is kind of unreasonable, IMO. The Jest team specifically built in those escape hatches for people like yourself that want further customization.

Right, and what I'm suggesting is the idea of least surprise. Because the escape hatch exists, it's surprising to me that it doesn't behave as expected.

I'm done bikeshedding. I'll wait for a member of the project to comment.

I'm switching some of my projets from AVA to Jest (still like AVA but Jest has a better "out-of-the-box" support for React/UI components IMO) and I miss some of those as well!

only is actually a very useful one, when developing you usually focus on writing one test and that cleans up the output.

todo is also very useful as I like to plan my tests in advance, I usually write a bunch test.todo and as I write them AVA nicely shows my progress. For now I'm writing empty tests in Jest:

it('does stuff ', () => {

});

but Jest displays those as successful tests which is not really what I want, it doesn't help much with my organisation.

Those features are not that important but nice to have and will greatly improve the general developer experience 馃槉

i really wanted those too. I aliased some of them here
https://github.com/facebook/jest/pull/1632

failing and todo seem to be pretty awesome too, but the'll require a little more code :)

I don't see value in test.failing it seems too easy to forget to fix them.

test.todo I'm ok with, should be easy to implement as test.todo = title => xit(title, () => {}).

I don't see value in test.failing it seems too easy to forget to fix them.

I'm ok to leave that one off. I've never really used it before.

@dmitriiabramov test.todo seems easy enough to add. Do you mind helping with this since you already added all the other ones from this issue?

the docs seem to say that test.skip() is available now, is that not the case? I can just use xit insead for now, but it was confusing. jest version 15.1.1 says it.skip is not a function.

ah, we accidentally pushed the website but not a release yet. There'll be a new release in the next few days.

Nice!

@cpojer are you still opposed to test.failing?

I find it an awesome way to keep around todos in the code itself, instead of in issues (or docs). I may know how I want something to behave, even though I'm unable/don't have the time to implement it right away. When I feel like hacking around, I can just grep for .failing and see if there are any low-hanging fruit. If tests are already written, it's a head start

Another use case, which is highlighted in Ava's docs, is that people can contribute failing tests for expected behavior as a separate thing from fixing it.

I can implement this if it's going to be accepted, but don't want to spend time on it since you've said in this issue you don't want it.

@SimenB yeah, I'm fine with it.

Cool! I've spun up a separate issue for it as this has been closed for a year. #4627

Was this page helpful?
0 / 5 - 0 ratings