12/30/18

Is it complicate to write unit tests for your React app?

Not at all!
All you need is to install jest testing framework:

npm add --D jest babel-jest babel-preset-env babel-preset-react react-test-renderer
Add "test" script to "scripts" section in package.json file

  "scripts": {
    "start": "webpack-dev-server --open",
    "test": "jest",
Now you have the testing environment configured and running.
And you can start with adding some very simple unit test
You can create it on some file which has ".test" in its name - like example.test.js

test('adds 1 + 2 to equal 3', () => {
  expect(1 + 2).toBe(3);
});
After running
npm test
the result will be something like this
Now nobody can say about you that you never wrote a single test

12/11/18

Distructuring cheatsheet

Since I keep find myself forgot the ES6 destructuring syntax again and again I decided to publish this cheatsheet:

If you want to print one property of object:


const object = {name:'vasia'};
const {name} = object; 
console.log(`${name}`); // vasia 


If you want to this property to be named differently (bio)


const object = {name:'vasia'};
const {name: bio} = object; 

console.log(`${bio}`); // vasia 


If this property is inside other property (person)


const object ={person: {name:'vasia'}};
const {person:{name}} = object;

console.log(`${name}`); // vasia 
Hope this post will make me remember...

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...