TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Jest – Painless JavaScript Testing

202 点作者 huan9huan超过 8 年前

19 条评论

orta超过 8 年前
I&#x27;m a big fan of Jest - if you&#x27;re using Jest with Visual Studios Code, I&#x27;d recommend looking at my extension that gives you a mode IDE-like experience.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;orta&#x2F;vscode-jest" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;orta&#x2F;vscode-jest</a>
评论 #13131017 未加载
评论 #13130896 未加载
评论 #13130106 未加载
rileyt超过 8 年前
Jest used to have a lot of problems and was poorly maintained.<p>Over the past few months, that has changed entirely. Improved speed, lots of bug fixes, snapshot tests and general ease of setup with React projects have all really helped.<p>Jest is now the test framework I would suggest for anyone starting a new React project.
评论 #13129695 未加载
评论 #13129857 未加载
评论 #13129730 未加载
wwalser超过 8 年前
I have a strange history with JS test libraries. Of the 4 that I&#x27;ve used, I&#x27;ve fixed bugs in 3 of them within a week of first picking it up. QUnit, Sinon and Jest.<p>This isn&#x27;t commentary on the quality of Jest. After turning off auto-mocking and instead only using the mocking when I really needed it, I ended up using it for a moderately successful side project and enjoyed the experience.
评论 #13128913 未加载
评论 #13128666 未加载
评论 #13128630 未加载
jcoffland超过 8 年前
There&#x27;s no such thing as painless testing.
评论 #13129583 未加载
评论 #13129110 未加载
评论 #13129598 未加载
评论 #13129503 未加载
haney超过 8 年前
I&#x27;ve been working on a React Native project and I really enjoy how easy jest is to use. It&#x27;s hard to tell from this post though, is there something new&#x2F;specific about it? Or are we all just agreeing that it&#x27;s awesome?
franciscop超过 8 年前
I just migrated a project[1] to Jest. Now I totally think that Jest is AWESOME.<p>Before I was mangling with Grunt and PhantomJS, but due to PhantomJS version being back ages I couldn&#x27;t really test ES6 so I had to do a hybrid and running mocha in an actual browser, and the rest of the dev stack in grunt. Now I am able to do it all automatically. Not only that, but jest includes a browser by default which supports ES6 and an assertion library, so just with &#x27;jest&#x27; I am doing the same that I did before with mocha, chai and PhantomJS (+ the pain of installing PhantomJS separately).<p>I am not <i>so much</i> into React, but I just fell in love with Jest. Testing will be something totally different from now on, thank you Facebook.<p>[1] <a href="http:&#x2F;&#x2F;github.com&#x2F;franciscop&#x2F;superdom.js" rel="nofollow">http:&#x2F;&#x2F;github.com&#x2F;franciscop&#x2F;superdom.js</a><p>PS, it was a bit more difficult to integrate Jest into Grunt and I get it without the colors, but I&#x27;m sure I&#x27;ll find a solution soon-ish.
wildpeaks超过 8 年前
Jest sounds good on paper, it&#x27;s great it exists and it definitely has potential and even improved a lot recently (and I usually try every new version that come up), however I have two pain points with it that prevent me from switching to Jest for now:<p>- it uses regexes instead of globs, so you can&#x27;t just give it the list of tests like you would with Mocha or electron-mocha (e.g. something like &quot;jest src&#x2F;* * &#x2F;*.tests.js&quot;)<p>- it excludes paths that include &quot;node_modules&quot; and it&#x27;s not just a default (which would be fine), it&#x27;s hardcoded, so you can forget about local modules, or dependencies that use local modules<p>Fortunately, there are already open issues for both, so that might improve in the future :)<p>---<p>Edit: I had to add extra spaces in the glob example (so it&#x27;s slightly incorrect) because HN formatting seems to prevent using &quot;double star&quot;.
评论 #13128770 未加载
评论 #13129556 未加载
BJanecke超过 8 年前
This might be a bit frivolous.<p>But<p>Jest has gotten a whole lot better over the last few months. It used to be slow, cryptic and dogmatic. Now it&#x27;s fast, transparent and open to debate.<p>Great job Jest team!<p>I would qualify that but I started this comment saying it was going to be frivolous. If enough people care however I&#x27;ll expand on this.
misiti3780超过 8 年前
I have used jest and i have used mocha. I use mocha because I got sick of having to &quot;unmock&quot; everything in jest tests. People have complained that jest is slow, that was never a problem I encountered.<p>The unmock becomes very annoying after a while.
评论 #13128491 未加载
评论 #13128426 未加载
评论 #13128486 未加载
spraak超过 8 年前
Two questions:<p>1. What good books (or repos) that use JS can you recommend for writing good tests?<p>2. What advantages does Jest have over Jasmine?
评论 #13130808 未加载
CoryG89超过 8 年前
We use usually use a mocha&#x2F;chai&#x2F;sinon combo for our testing. Can anyone that has used this make a comparison with that?<p>Looks like jest tries to cover all three.
评论 #13130855 未加载
batmansmk超过 8 年前
The last versions are for us better than the other tool. The snapshot feature is pretty neat.
efrafa超过 8 年前
Are you forced to use expect().to... or you can plugin any assert library ? (I get the benefits of expect but I still prefer assert style)
评论 #13128966 未加载
petetnt超过 8 年前
Jest has taken great steps forward in the oast year and I see the momentum only going up. Kudos to the whole team!
kybernetikos超过 8 年前
Snapshot testing overconstrains your tests, and encourages people who see tests breaking just to rerun the snapshot without thinking too much.<p>The painlessness comes with a cost.
评论 #13129669 未加载
Nitramp超过 8 年前
This doesn&#x27;t do browser testing (like Karma), it&#x27;s just an alternative to mocha, right?
评论 #13130127 未加载
评论 #13128775 未加载
aikah超过 8 年前
Still sticking to Jasmine. Simple and efficient and no need for nodejs to run tests.
krrkrrmjao超过 8 年前
do we really need MORE testing frameworks? the devs should join jasmine instead
gondo超过 8 年前
i&#x27;m surprised this does not use Yarn