A typical spec would be like:
But if you run the spec, it would result in will found
$.fn.aaa
to be undefined. The reason for that is because Squire is creating a new context for
require.js
, where
a.js
get a self ‘
$
‘ reference, which is different from the outside one.
To fix this, you need to inject the jQuery from outside to Squire:
Note that you cannot just feed in
{jquery:$}
to
.mock()
, as
require.js
will think the instance
$
, which is a
function
as the factory method.
It took me a day to figure out, so I documented it….