Sharing Top Content from the Angular-sphere.

Testing an AngularJS app with Jest – Zenika

“Testing an AngularJS app with Jest” by @Swiip  #reactjs #angularjs #javascript #testing

  • Here’s an extract of the Karma config.Trying JestIn this context, I read about jsdom and thought that it could be huge to remove the real browser part since pure JavaScript implementations differences are not an every day problem anymore.
  • For a reason or another, I was quite sure I would have to refactor, even for a simple thing, every single test.In reality, I only had to point my source folder and write a tiny script which imported my tests common lib and my tests were passing.The biggest part of…
  • For the execution of all tests once without coverage, Karma takes 47s in total.
  • Jest works very differently, it only runs the modified test and takes approximatively 1s to detect the change and another one to execute it.A final but important point is that with the stack Karma / Webpack / Babel we have never figured out a good solution to have a robust…
  • Jest is far more straightforward, The error reports are just perfect with only references to our Babel source code et good line numbers.ConclusionJest popularity is shamefully restricted to the React world and really deserves to cross that frontier since it’s a very good agnostic solution for frontend testing.I didn’t find…

I will not try to write the ultimate guide to test an AngularJS app with Jest, this article is only my feedback after trying Jest on my project. First, let me add some context. I was a huge AngularJS…

I will not try to write the ultimate guide to test an AngularJS app with Jest, this article is only my feedback after trying Jest on my project.TL;DR It works pretty well :)First, let me add some context. I was a huge AngularJS fan and slowly drifted to React. That’s probably why I was aware of Jest and wanted to try it. Still, my biggest ongoing project uses AngularJS, it’s the member part of the new data exchange plateforme: Dawex (https://www.dawex.com/)Also, I’m one of the developers of the Yeoman Fountain generator (fountainjs.io) and as such, pretty familiar with the use and configuration of new Web tooling.The app is, I think, a pretty modern AngularJS app. It’s fully component oriented with AngularJS 1.5.x and uses NPM, Webpack and Babel for tooling. We even added some new stuff like RxJS and Redux.The test environment is based on Karma and Jasmine. We use the karma-webpack plugin and tests are running in Chrome since we encountered some problems with PhantomJS.Tests work with watching mode and coverage but there are some pain points remaining. The test bootstrap is very slow as Webpack has to build the whole bundle. Then, it starts a real Chrome (which need the xvfb trick on CI) and we didn’t find a way to have proper source-mapping (through Babel / Webpack / Karma) for proper error stacktraces. Finally but perhaps the most important, the global runtimes seems to be slow (real figures comes next).Here’s an extract of the Karma config.Trying JestIn this…

Testing an AngularJS app with Jest – Zenika

Comments are closed, but trackbacks and pingbacks are open.