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

Cannot determine how Jest is skipping tests #4763

Closed
amandapouget opened this issue Oct 25, 2017 · 32 comments
Closed

Cannot determine how Jest is skipping tests #4763

amandapouget opened this issue Oct 25, 2017 · 32 comments

Comments

@amandapouget
Copy link

When I run Jest in watch mode and hit "a" (to run all tests), Jest still skips 18 test files. I cannot find anything anywhere in my code that would explain how or why it is doing this.

I welcome suggestions. Not sure what code even to put up in reporting this, as my test files show nothing interesting (no Jest settings or anything like that).

@thymikee
Copy link
Collaborator

Hey @mandysimon88. Why are you not sticking to the issue template?
Does skip means it doesn't see them, or mark as skipped? If the former is true – it's your testRegex or testMatch not picking up these files, if the latter – you have tests without function as a second argument. Closing.

@amandapouget
Copy link
Author

amandapouget commented Oct 26, 2017 via email

@cpojer
Copy link
Member

cpojer commented Oct 26, 2017

Is your project in a folder that is ignored by Jest, like node_modules or a cache directory or something like that?

@adambergere
Copy link

i'm having a similar issue with Jest. Is there a place to check how it's choosing which files to ignore?

@SimenB
Copy link
Member

SimenB commented Nov 1, 2017

If you do jest path/to/file.js it will usually print why it's ignored

@ryanflorence
Copy link

Same, I'm seeing 6 skipped tests, I'm pointing at my tests folder, so there shouldn't be anything weird it's picking up, my code doesn't have .skip anywhere.

@SimenB
Copy link
Member

SimenB commented Nov 29, 2017

Do you have an example of a skipped test?

If you point jest directly at a test file with skipped tests, are they still skipped?

@drdpedroso
Copy link

I'm having the same issue here, already deleted the cacheDirectory and the tests are also skipped when pointing directly to the test file.

Here's one sample

import React from 'react'
import StarRatingComponent  from '../../../../src/components/common/starRatingComponent'
import renderer from 'react-test-renderer'
import {expect} from 'chai'
import {shallow} from 'enzyme'

describe('<StarRatingComponent />', () => {
    it('should render correctly'), () => {
        const component = renderer.create(<StarRatingComponent/>)
        expect(component).toMatchSnapshot()   
    }
    it('should change state'), () => {
        const component = shallow(<StarRatingComponent/>)
        component.instance().rate(1)
        expect(component.state().rating).to.equal(1)   
    }
})

@SimenB
Copy link
Member

SimenB commented Dec 3, 2017

Can you paste in the output from jest when skipping?

@drdpedroso
Copy link

screen shot 2017-12-03 at 12 00 39 pm

After that, it only shows my coverage table

My jest version is v21.2.1

@SimenB
Copy link
Member

SimenB commented Dec 3, 2017

Oh, I see it.

it('should render correctly'), () => { has a closing paren it shouldn't

@drdpedroso
Copy link

lol! My bad, thanks @SimenB !

@JonathanTR
Copy link

Similar issue. No .only or .skip tags. Running jest --verbose does not seem to indicate which tests were skipped either. There was some discussion a while back on this PR about filtering output for skipped tests. At the time, it sounded like there would be an --expand flag (although I'm not sure how that differs from --verbose) to show the filtered output.

Am I missing something? Seems like there should be a way to figure out which tests are being skipped without hunting for missing parens.

@SimenB
Copy link
Member

SimenB commented Jan 22, 2018

Can you provide a repro?

@SimenB
Copy link
Member

SimenB commented Jan 22, 2018

I didn't even know about the expand flag! 😅 Passing verbose should really trigger that...

Do you get any better output passing both --expand and --verbose?

The docs for expand doesn't mention the skipped test behavior...

@JonathanTR
Copy link

JonathanTR commented Jan 22, 2018

Working with a private company repo, unfortunately! I don't see any difference in adding both flags, although adding --expand didn't seem to produce any different behavior. I tried upgrading to the latest Jest (I was only a couple versions behind), but didn't change anything, either. If I'm able to track down the issue, I'll create a small demo repo

@SimenB
Copy link
Member

SimenB commented Jan 23, 2018

You can try to activate the lint rule which looks for skipped tests, maybe it can track it down for you?

@ghost
Copy link

ghost commented Mar 6, 2018

I'm having this problem as well. The "lint rule" you linked to makes no sense to me; all it says is "here's how to not skip tests: these are the ways to skip tests...." --very confusing.

@SimenB
Copy link
Member

SimenB commented Mar 6, 2018

@chaim-sw Add it to your eslint setup and run it against your code.

See https://eslint.org/docs/user-guide/getting-started and https://eslint.org/docs/user-guide/configuring for configuring plugins

@city41
Copy link

city41 commented Mar 18, 2018

I came here because Jest was skipping tests. In my case it was a it.only causing it. If anyone else is coming from Mocha, this can be surprising in Jest. In Jest. it.only only scopes to one file, since tests run in parallel. Making it less obvious when you accidentally leave one in.

@rickhanlonii
Copy link
Member

I've hit this a few times (especially with the jest-eslint-runner)

A custom reporter can help here so I just published jest-skipped-reporter

It's super basic, but should help with debugging 👌

@JonathanTR
Copy link

JonathanTR commented Mar 23, 2018

It seems like the ideal behavior would be to have the default reporter show the location of the skipped tests along with PASS/FAIL tests. So adding a yellow SKIP flag here:

screen shot 2018-03-23 at 10 26 09 am

I'd be happy to throw something together. I'm not super familiar with the codebase, but it looks like most of the changes would be needed in the default reporter, summary reporter, and get_result_header

Then perhaps "Watch usage" could have options like "show only failing tests" or "filter skipped tests" to address the issue raised in #2169? Or vice versa: we could have an option in "Watch usage" to show skipped tests.

Thoughts?

@hipstersmoothie
Copy link

Yeah i think it would be way more useful to say SKIP instead of FAIL

@rickhanlonii
Copy link
Member

we could have an option in "Watch usage" to show skipped tests

This is a great use case for the new watch mode plugin system cc @rogeliog

@JonathanTR yeah, that's exactly where this would get added. What would you show if a file has both a failed test and a skipped test?

Also, since the default reporter prints the results of the file and not the individual specs in the file, you'll still need a way to see which tests within a suite were skipped. I suppose we could only show that there was a skipped test in the file for the default reporter, and recommend dropping into jest-skipped-reporter or the watch mode to see the individual skipped specs

@JonathanTR
Copy link

@rickhanlonii That's a great point. I think I would expect to see a failed test take precedence over a skipped one? So if I fixed the failing test, the file would start showing SKIP instead of FAIL in the summary.

Re: displaying individually skipped tests, Jest already shows individual test results when you filter for a file, so it makes sense me that the default behavior would be to see them there:

screen shot 2018-04-25 at 9 48 48 am

I wasn't aware of watch mode plugins, but they sound cool! For folks following along, looks like there is a statement of intent here and a pull request here.

@JonathanTR
Copy link

Addendum: it looks like we already show the number of tests skipped in a file:
screen shot 2018-04-25 at 10 02 11 am

@deanrad
Copy link

deanrad commented Jun 14, 2018

This is a little unfortunate, in that there's no advantage, for a single test, in displaying skipped 1 test instead of the name of the skipped test. Those like me who only skip one at a time (for the next feature, a draft test) are punished! Also --expand --verbose does nothing. Current version of Jest.

@ewolfe
Copy link

ewolfe commented Jun 28, 2018

I had some tests that were being skipped, turns out it was because they were wrapped in xdescribe (In the process of porting from a jasmine setup).

@JeremyEllingham
Copy link

I didn't have any 'it.skips', but I did have a rogue 'it.only' that I'd forgotten about that was causing other tests not to run. Easily located with --verbose.

@JulianLang
Copy link

For anyone having the same problem: in my case it was a "fit", which caused other tests of the suite to be skipped.

@markcorrea
Copy link

I had 13 skipped files and couldn't find any way to find them usint --verbose or --expand. Turns out that I had a file jest-config.json in which had the verbose variable declared as false, so it was hidding the details even when I added the --verbose flag in the terminal. Once I turned it to true in the json file, the details displayed and also the skipped files.

PS: I also added the expand: true inside the jest-config.json file.

For the reason why it was being skipped, it was a it.skip test.

Screen Shot 2020-10-16 at 16 35 44

@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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests