React-starter-kit: Please use some test coverage

Created on 14 Nov 2015  路  12Comments  路  Source: kriasoft/react-starter-kit

It is difficult to use Jest; it would be good to have test coverage off the included components so we can have some confidence in the ability of Jest to work with react :D

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Most helpful comment

I did a test in my own project. It seems to be working... The yellow part means it's a not-covered branch

image

All 12 comments

+1

+1 or use enzyme

+1

Yea, Jest doesn't seem to actually work out of the box.

what I have found is that Jasmine can test general components -- straight unit tests -- but the Jest stuff is just not friendly.

It's quite simple @bingomanatee @kriasoft
yarn add --dev nyc

"test:cover": "nyc --require babel-register mocha \"src/**/*.test.js\" --require test/setup.js",

@Stupidism
Thanks for your solution.
I have tried #1213 in my project, but it seems that nyc doesn't work with inline conditional rendering.
It seems that the conditions within the conditional rendering would not be considered as multiple branches by nyc.

Is there a walk around for this issue, or is conditional rendering not a recommended way in react starter kit?

Pls tell me if you need more information.

I think the problem is jsx is not supported well. @visualskyrim
I don't know how to config istanbul or nyc to support jsx. It seems istanbul is the only repo doing a good coverage work. However, the original author didn't maintain it since 8 months ago. Now there's a new group or person istanbuljs is restarting the project, so we should be patient.

If you jsx support is OK. Have you tried to write in multiple lines like the demo?

    <div>
      {isLoggedIn ? (
        <LogoutButton onClick={this.handleLogoutClick} />
      ) : (
        <LoginButton onClick={this.handleLoginClick} />
      )}
    </div>

If it's not working, either. Propose an issue in repo nyc or istanbuljs

I did a test in my own project. It seems to be working... The yellow part means it's a not-covered branch

image

@Stupidism

Thanks a lot!

It's now working well on my project.
I'm still not sure why it didn't work in the first place. Sorry for the incorrect information I put above.

Was this page helpful?
0 / 5 - 0 ratings