1

For UI automation, I am trying to add unique id for React component. before adding the ID, my test cases are [passing for finding child component. but after adding id with:

  <Fragment>
     <UIDConsumer>    
       { (id  => <div id={id} >
       <CustomComponent/> 
       </div>})
    </Fragment>

in my jest Unit test, is failing

 wrapper = mount(
            <Provider>
              <ViewComponent/>
            </Provider>
          );
      it("CustomComponent component", () => {
            const CustomComponent = wrapper.find(CustomComponent);
            expect(CustomComponent).to.have.lengthOf(1);
      });
skyboyer
  • 22,209
  • 7
  • 57
  • 64
Snehal
  • 23
  • 2
  • A unit test should receive value for custom components 1 but received 0 instead. – Snehal Apr 24 '19 at 22:54
  • I followed https://codeburst.io/unique-ids-and-where-to-find-them-14020ddbc964, an example to generate id – Snehal Apr 24 '19 at 22:55

0 Answers0