This article is about fixing Module not found in jest tests in FormKit Auto-Animate
  • 29-Jan-2023
Lightrun Team
Author Lightrun Team
This article is about fixing Module not found in jest tests in FormKit Auto-Animate

Module not found in jest tests in FormKit Auto-Animate

Lightrun Team
Lightrun Team

Explanation of the problem

This is an issue when running tests on a typescript React application utilizing the auto-animate library and Jest as the testing framework. The error message displayed is “Cannot find module ‘@formkit/auto-animate/react’ from ‘src/…/a_path_to_my_component'”. The application runs without issue when executed, however the issue only occurs during testing. The versions of node, npm and react-scripts being used are: node v16.15.0, npm v8.5.5 and react-scripts v5. The package.json file for the application is also provided for reference.

Troubleshooting with the Lightrun Developer Observability Platform

Getting a sense of what’s actually happening inside a live application is a frustrating experience, one that relies mostly on querying and observing whatever logs were written during development.
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.

  • Instantly add logs to, set metrics in, and take snapshots of live applications
  • Insights delivered straight to your IDE or CLI
  • Works where you do: dev, QA, staging, CI/CD, and production

Start for free today

Problem solution for Module not found in jest tests in FormKit Auto-Animate

If you are encountering a “Module not found” error when running Jest tests for FormKit Auto-Animate, there are a few potential solutions you can try:

  1. Make sure that the module in question is correctly imported in the file where the error is occurring. Check for any typos or syntax errors in the import statement.
  2. Ensure that the module is installed and listed as a dependency in your project’s package.json file. If it’s not, you can install it by running the appropriate command (e.g. “npm install –save [module name]”).
  3. Try running “npm install” or “yarn install” in the root directory of your project to ensure that all dependencies are correctly installed.
  4. Check your Jest configuration to make sure that it is correctly set up to handle the module resolution of your project.
  5. Sometimes, the problem is with the file that is trying to import the module, it is not being transpiled correctly, you can try adding the module to the transformIgnorePatterns in your jest.config.js file.
  6. If the above solutions do not work, there may be an issue with the version of the module you are using. Try updating it to the latest version or using a compatible version.
  7. Finally, you can check if the problem is with the FormKit Auto-Animate library, you can try to reproduce the error with the example from the library documentation.

Other popular problems with FormKit Auto-Animate


One popular problem with FormKit Auto-Animate is that the animations do not work as expected on Internet Explorer. This is due to the fact that Internet Explorer does not fully support the CSS3 animations that FormKit Auto-Animate uses.


To solve this issue, a polyfill can be implemented to add support for CSS3 animations on Internet Explorer. This can be done by adding a library such as “animate.css” or “Animate.js” to the project, which will provide the necessary animation functions for Internet Explorer. Additionally, it is recommended to include a fallback animation for browsers that do not support CSS3 animations.


Another common problem with FormKit Auto-Animate is that the form fields do not properly align with the labels on mobile devices. This is often caused by the use of fixed widths and positions for the form fields, which do not adapt to the smaller screen sizes of mobile devices.


To solve this issue, it is recommended to use responsive design techniques for the form fields. This can be achieved by using CSS media queries to adjust the width and position of the form fields based on the screen size of the device. Additionally, it is also recommended to use a mobile-first approach to design the form, which will ensure that the form fields are properly aligned on mobile devices.


A third popular problem with FormKit Auto-Animate is that the form validation is not working properly. This is often caused by incorrect use of JavaScript or jQuery code, which is responsible for handling the form validation.


To solve this issue, it is important to ensure that the JavaScript or jQuery code is properly implemented and that all necessary form validation libraries have been included in the project. Additionally, it is recommended to thoroughly test the form validation on various devices and browsers to ensure that it is working properly. If necessary, it may also be helpful to consult the FormKit Auto-Animate documentation or seek assistance from the FormKit Auto-Animate community for guidance on how to properly implement form validation.

A brief introduction to FormKit Auto-Animate

FormKit Auto-Animate is a library that allows for smooth animations and transitions when dealing with forms in React applications. It uses the React Transition Group library to handle the animation logic and provides a set of higher-order components that can be used to wrap form elements in order to add animation. By default, the library provides several pre-defined animations such as slide, fade, and zoom, but it also allows for custom animations to be defined.

The library also provides a way to easily animate form elements based on their state, such as when they are focused, active, or have been filled in correctly. This allows for a more polished and user-friendly experience when interacting with forms in the application. Additionally, the library also provides a way to easily animate the submission of the form, providing visual feedback to the user when the form has been successfully submitted.

Most popular use cases for FormKit Auto-Animate

  1. FormKit Auto-Animate is a powerful tool that allows developers to easily create and manage animations within their web applications. It can be used to create a wide variety of animations, such as page transitions, form submissions, button hovers, and more. This can greatly enhance the user experience by making the application more interactive and visually appealing.
  2. FormKit Auto-Animate can be easily integrated into a web application using a simple JavaScript code block. This allows developers to quickly and easily add animations to their application without having to write complex code or rely on external libraries.
  3. FormKit Auto-Animate also provides a wide range of customization options, allowing developers to fine-tune the animations to their specific needs. This includes options for adjusting the duration, easing, and delay of animations, as well as the ability to create custom animations using keyframe animations. This allows developers to create animations that are tailored to their specific application and user requirements.

It’s Really not that Complicated.

You can actually understand what’s going on inside your live applications.

Try Lightrun’s Playground

Lets Talk!

Looking for more information about Lightrun and debugging?
We’d love to hear from you!
Drop us a line and we’ll get back to you shortly.

By submitting this form, I agree to Lightrun’s Privacy Policy and Terms of Use.