lundi 28 janvier 2019

indexedDB testing Jeste Enzyme -TypeError: Cannot read property 'open' of undefined

Aplication working fine but when i test then it crashed.

this is pice of code where is something wrong.. i think

componentDidMount = async() => {
    try{
      const request = await window.indexedDB.open("QuestionData",1)

      request.onsuccess = (event) => {
        const db = request.result;
        const transaction = db.transaction('Questions' , "readwrite");
        const store = transaction.objectStore('Questions');
  
        const get = store.get(1)
        get.onsuccess = () =>{ 
          this.setState({
            data: get.result.data
          })
        }
      }

    }catch(err){console.log(err)}
  }

and this is a pice of test

test('should render btn', () => {
  const wrapper = mount(<App />)
  const btn = wrapper.find('.btn')
  expect(btn.length).toBe(1)
})

now Error !

console.log src/App.js:36 TypeError: Cannot read property 'open' of undefined

Aucun commentaire:

Enregistrer un commentaire