Skip to content

fix(react): src/index.test.js fails on develop due to missing swiper/element/bundle module #1191

@7vignesh

Description

@7vignesh

Bug Report

Summary

src/index.test.js fails to run on the develop branch and has been broken before any recent changes. This is a pre-existing issue unrelated to any feature work.

Steps to Reproduce

cd packages/react
npx jest src/index.test.js --no-coverage


Cannot find module 'swiper/element/bundle' from 'src/views/ImageGallery/Swiper.js'

Require stack:
  src/views/ImageGallery/Swiper.js
  src/views/ImageGallery/ImageGallery.js
  src/views/AttachmentHandler/ImageAttachment.js
  src/views/AttachmentHandler/Attachment.js
  src/views/AttachmentHandler/Attachments.js
  src/views/AttachmentHandler/index.js
  src/views/Message/Message.js
  src/views/MessageAggregators/common/MessageAggregator.js
  src/views/MessageAggregators/MentionedMessages.js
  src/index.test.js


Root Cause

swiper/element/bundle is not installed in [node_modules](vscode-file://vscode-app/c:/Users/vigne/AppData/Local/Programs/Microsoft%20VS%20Code/61b3d0ab13/resources/app/out/vs/code/electron-browser/workbench/workbench.html) at test time, so Jest cannot resolve it when loading the full component tree through src/index.js. There is also no jest.config.js or moduleNameMapper stub to mock it out during tests.

Expected Behaviour

npx jest --no-coverage should pass without failing due to a missing or unresolvable package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions