Skip to main content

Posts

Showing posts from June, 2020

React Testing with Jest and Enzyme

Install enzyme, and enzyme-adapter-react-16 using npm Add the following to setupTests.js file of your project import  {  configure  }  from   'enzyme' ; import   Adapter   from   'enzyme-adapter-react-16' ; configure ({  adapter :   new   Adapter () }); Here is a basic test import   React   from   'react' ; import  {  mount  }  from   'enzyme' ; import   Note   from   './Note' ; const   props  = {      note :   "Test Note" ,      index :   0 ,      removeHandler :   jest . fn () } describe ( 'Note' , ()  =>  {      let   note  =  mount ( < Note   { ... props }   /> );      it ( "renders the note text" , ()  =>  {        ...