Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

callback function for `scroll` event doesn't get covered by enzyme test. (React.js)

$
0
0

This is my part of React component

...  componentDidMount(): void {    window.addEventListener('scroll', this.handleScroll, true);  }  handleScroll() {     const hello = 'assign';     this.setState({blah: 'blah'}); /// whole function is not covered.  }...

enzyme test

describe('when is scrolled', () => {  beforeEach(() => {    wrapper.simulate('scroll', true); <-- simulate scroll  });  test('should match snapshot', () => {    expect(wrapper).toMatchSnapshot(); <<< should cover `handleScroll`  })});

This should cover handleScroll but enzyme test doesn't cover the whole function (for code coverage)


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>