glidejs / glide

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
https://glidejs.com
MIT License
7.21k stars 768 forks source link

TypeError: _glide.default is not a constructor #636

Open arslanalidev opened 1 year ago

arslanalidev commented 1 year ago

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();
      });
    });
VasekProchazka commented 10 months ago

Do you find any solution for this issue ?

ericmorand commented 10 months ago

@arslanalidev what is the error?

TypeError: _glide.default is not a constructor

or

TypeError: Cannot read property 'querySelector' of undefined