Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery is not defined #236

Open
kdillon opened this issue Mar 14, 2019 · 4 comments
Open

jQuery is not defined #236

kdillon opened this issue Mar 14, 2019 · 4 comments

Comments

@kdillon
Copy link
Collaborator

kdillon commented Mar 14, 2019

Upon funcunit import, we get... "

VM180:9958 Uncaught ReferenceError: jQuery is not defined
at :9958:21
at global.define (:73:36)
at :9955:1
(anonymous) @ VM180:9958
global.define @ VM180:73
(anonymous) @ VM180:9955

"

This could be a regression of #187 (similar syndrome), but I think jQuery is undefined prior to the failure moment described in 187.

Chasen suspects it might be related to changeset: #230
... and I think he's on to something.

@chasenlehara
Copy link
Member

A little more info… here’s what the built file looks like:

define('global', function (require, exports, module) {
    require('funcunit');
    var FuncUnit = window.FuncUnit || {};
    window.jQuery = jQuery;
    module.exports = FuncUnit;
});

I put a debugger statement before window.jQuery = jQuery to see the value of jQuery

  • 3.5.0: jQuery is undefined
  • 3.6.2: jQuery isn’t defined, hence the reference error

@matthewp
Copy link
Contributor

Sounds like the global module is wrong then. I don't know where this module is but if it wants to set jQuery on the window it should be importing it from within FuncUnit now.

Having jQuery be a global in the non-global build was a longstanding cause of pain for people.

@chasenlehara
Copy link
Member

Here’s that issue I think: Do not set window.jQuery

I think this is the global module: https://github.com/bitovi/funcunit/blob/master/global.js

Is the solution to add var jQuery = require("funcunit/browser/jquery"); to the global build?

Or should this line:

window.jQuery = jQuery;

…be changed to:

window.jQuery = FuncUnit.jQuery;

…or should the global build not set window.jQuery at all?

I’m not familiar with how FuncUnit is supposed to work with its own version of jQuery vs. imported versions, hence the uncertainty on my end. 😬

@matthewp
Copy link
Contributor

I'd say not set window.jQuery at all. FuncUnit uses it internally, but uses its own version now that is gets through the module loader. So I don't think setting window.jQuery is a good idea. The reason for getting rid of it was that it interfered with other jQuerys on the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants