fullcalendar: Jest test runner cannot find fullcalendar modules
Bug
See this repository for reproduction steps: https://github.com/sgoodrow/test-fullcalendar-v5
Clone and run:
yarn installyarn test
FAIL src/App.test.js
● Test suite failed to run
Cannot find module '@fullcalendar/react' from 'DemoApp.jsx'
However, Jest was able to find:
'./DemoApp.jsx'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
However, Jest was able to find:
'./App.css'
'./App.js'
'./App.test.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
1 | import React from "react";
> 2 | import FullCalendar from "@fullcalendar/react";
| ^
3 | import dayGridPlugin from "@fullcalendar/daygrid";
4 |
5 | export default class DemoApp extends React.Component {
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (src/DemoApp.jsx:2:1)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.985s
This repository was created by:
- Running create-react-app
- Installing the v5 react fullcalendar per these instructions
React/Vue/Angular/etc
I happen to be using React, but the import error occurs for the plugin files, too, so this is a broader issue than just the React connector. AKA, if you change the import order:
import React from "react";
import dayGridPlugin from "@fullcalendar/daygrid";
import FullCalendar from "@fullcalendar/react";
You will see Jest get hung up on daygrid instead:
FAIL src/App.test.js
● Test suite failed to run
Cannot find module '@fullcalendar/daygrid' from 'DemoApp.jsx'
However, Jest was able to find:
'./DemoApp.jsx'
Note also that this does not occur with 4.x.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 16 (5 by maintainers)
Is there a known workaround for this that I can implement temporarily?
This is released in the v5 release candidate
All packages simply use a
mainfield now. If there are further problems, please open a new ticket.in the
package.jsonof each package I specified amoduleonly, because I assumed all environments that are able to consume ES modules would know to look for this, but apparently node-only environments like jest don’t. I’ll just add amainback in, I don’t see any harm in that. will solve this issue.Agree with @duhseekoh. I was stuck on this for the entire day today trying to make it work, still with no solution. I don’t use next.js so cannot do what other issues suggest. Please output two variants. github.com/elastic/ui does it so there’s a good example.