question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test suite failed: jQuery is not defined

See original GitHub issue

Description

I have imported jquery and the resizable widget in a component in this way:

import $ from "jquery";
import 'jquery-ui/themes/base/resizable.css';
import 'jquery-ui/ui/widgets/resizable';

It worked fine but when I try to run the unit test it returns this error:

Test suite failed to run
ReferenceError: jQuery is not defined

what can I do? Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
gaearoncommented, May 24, 2017

Seems like it works with this:

import $ from "jquery";
import 'jquery-ui/themes/base/resizable.css';

window.jQuery = $;
require('jquery-ui/ui/version');
require('jquery-ui/ui/plugin');
require('jquery-ui/ui/widget');
require('jquery-ui/ui/widgets/mouse');
require('jquery-ui/ui/widgets/resizable');

I sent a PR: https://github.com/FrancescaBarbazeni/jquery-not-defined/pull/1.

I would add that this is pretty broken (on jQuery side) as it’s not really compatible with modern bundlers, and you might have better luck using React-specific libraries instead. But it seems to work.

Hope it helps!

1reaction
gaearoncommented, May 24, 2017

I’m not sure really, depends on what exactly you’re looking for. If I search for “resizable table reactjs” I find a bunch of components, maybe one will match your needs!

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs jest jQuery is not defined - Stack Overflow
Jest error: Test suite failed to run, how to solve? 4 · ReferenceError: window is not defined. I got this error when I...
Read more >
5 Easy Ways to Fix the "jQuery is Not Defined" Error - Kinsta
The "jQuery is not defined" error means a call for a specific jQuery that wasn't available when the website loaded. Here's how to...
Read more >
jQuery is not defined: Common causes and a simple solution
What are the common causes of jQuery is not defined? · 1. Your CDN-hosted jQuery might be blocked · 2. Your CDN-hosted jQuery...
Read more >
WordPress jQuery Is Not Defined Error: 4 Effective Ways to Fix It
WordPress jQuery is not defined error is usually caused by mistake in the code. Check out this article to learn 4 methods to...
Read more >
Uncaught ReferenceError: $ is not defined
Basically $ is an alias of jQuery() so when you try to call/access it before declaring the function, it will endup throwing this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found