Jest and the Component Driven Development (CDD) – Comunidad JS – Medium

#Jest and the Component Driven Development (CDD):  #ReactJS #JavaScript

  • Jest and the Component Driven Development (CDD)Testing React and React Native applications.We all knows about TDD right ?
  • I recently discovered other flow/flavor around React Components and Jest snapshot testing that makes me more happy and encourage me to write more tests.This approach makes the dev process a bit more fun that the other way around.
  • Then, when you´re confortable with your component code base and you have applied all the good practices out there, write the actual test, passing the required props to the component being tested and expect it to match the snapshot.Snapshot testingSnapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.The above statement, is from the Jest documentation, and it´s 100% true.
  • I’ve found snapshot testing to be a quick and fun way to test Components and make sure your UI does not change unexpectedly, which is a good thing.The test will fail if the two images do not match: either the change is unexpected, or the screenshot needs to be updated to the new version of the UI component.That means we are not passing the expected props to our component in some parts of our application or we have adjusted the component (because we´ve refactored it).
  • So either one or the other possibility, we need to update the test snapshot (If we´ve refactored it) executing in the terminal yarn test -u or go and fix the part in the application where we´re not using the component as we expect.Having a test coverage between 80 and 100% make us more confidents when we need to deploy to any environment and allows applications to be more robust and easy to scale.In closing, I really encourage React developers to use Jest for testing applications.

We all knows about TDD right ? Test Driven Development.
The philosophy behind it, is to start the development cycle with first writing a failing test and then writing the actual function, to make it…
Continue reading “Jest and the Component Driven Development (CDD) – Comunidad JS – Medium”

Testing with Mocha – Kevin Wang – Medium

Testing with Mocha  #tdd #react #mocha #javascript #reactjs

  • js file and running “npm test” in the console.var assert = function() { describe(‘#indexOf()’, function() { it(‘should return -1 when the value is not present’, function() { assert.equal(-1, [1,2,3].
  • indexOf(4)); }); });});The test should pass and you should see the below.From the example above though, the function that the test is testing for is written in the same file.
  • toFixed(2) }, sleepApneaIncrease: function(amount){ return (amount * 1.06).
  • toFixed(2) }, heartDiseaseIncrease: function(amount){ return (amount * 1.17).
  • toFixed(2) }, checkCondition: function(amount, condition){ switch (condition) { case “Allergies”: return case “Sleep Apnea”: return case “Heart Disease”: return default: return 0; } }}I store them all in an object so thatI am able to export out and require them when I need to.

My first experience with Mocha is at Flatiron. When we were doing Javascript labs/work we used Mocha to test out the code that we wrote, it made sure that the results are as we expected. This was my…
Continue reading “Testing with Mocha – Kevin Wang – Medium”

The Complete Web Development Tutorial Using React and Redux Coupon Save 67 %

The Complete Web Development Tutorial Using React and Redux
☞ 

#reactjs

  • It allows the developer to write apps regardless of the environment, resulting in more consistently running apps.
  • Redux is a predictable state container for JavaScript apps.
  • In order for a change to be made, an action is emitted, which does not result in the state of the app to be changed but rather a new object to be returned.
  • The course answers questions such as what is React and its basic features such as components, state, properties and lifecycle; what is Redux and its basic features such as state, store and reducers; and even how to combine them together to create a brilliant app.
  • The course includes everything you need to know about React and Redux.

Coupon 100 10 15 75 Master the professional web development techniques using React and Redux
Continue reading “The Complete Web Development Tutorial Using React and Redux Coupon Save 67 %”