glide icon indicating copy to clipboard operation
glide copied to clipboard

TypeError: _glide.default is not a constructor

Open arslanalidev opened this issue 3 years ago • 2 comments

I had make a slider with GlideJS. This widget is working fine. But when I am writing the jest test. My Test is failing, it's saying TypeError: Cannot read property 'querySelector' of undefined. Here is the complete error while I am playing the test case.

        TypeError: Cannot read property 'querySelector' of undefined

      55 |     const slider = new Glide(sliderRef.current, options);
      56 |
    > 57 |     slider.mount();
         |            ^
      58 |   }, [options]);
      59 |
      60 |   const handleOnMouseEnter = () => setNavigationVisible(true);

Here is the Test Suite which I write down.

    import React from 'react';
    import renderer from 'react-test-renderer';
    import Widget from './Widget';
    
    const mockArray = [
      { title: 'Mock Title 1', completed: false },
      { title: 'Mock Title 2', completed: false },
      { title: 'Mock Title 3', completed: false },
    ];
    describe('Widget', () => {
      it('renders Widget according to design', () => {
        const component = renderer.create(
          <Widget lessons={mockArray} title={'mock title'} />
        );
        const tree = component.toJSON();
    
        expect(tree).toMatchSnapshot();
      });
    });

arslanalidev avatar Dec 19 '22 10:12 arslanalidev

Do you find any solution for this issue ?

VasekProchazka avatar Aug 29 '23 08:08 VasekProchazka

@arslanalidev what is the error?

TypeError: _glide.default is not a constructor

or

TypeError: Cannot read property 'querySelector' of undefined

ericmorand avatar Aug 29 '23 10:08 ericmorand