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

Not patching Chai using RequireJS #29

Closed
davejacobs opened this issue Feb 20, 2013 · 1 comment
Closed

Not patching Chai using RequireJS #29

davejacobs opened this issue Feb 20, 2013 · 1 comment

Comments

@davejacobs
Copy link

I'm trying to get Chai/jQuery working with RequireJS, and I can't seem to get it to patch Chai. Specifically, I have the following in my runner.js file:

define(function(require) {
  var chai = require("chai"),
      mocha = require("mocha");

  require("chai_jquery");

  assert = chai.assert;
  should = chai.should();
  expect = chai.expect;

  mocha.setup("bdd");

  require(["../../spec/app_spec",
           "../../spec/app/views/login_layout_spec"], function() {
    mocha.run();
  });
});

And the following in my config.js file:

paths: {
  // ... Other paths
  chai: "../lib/chai",
  chai_jquery: "../lib/chai-jquery",
  mocha: "../lib/mocha"
},

shims: {
  mocha: { exports: "mocha" }
  // Have tried with and without this, which should be unnecessary:
  // chai_jquery: { deps: ["jquery", "chai"] }
}

When I run the specs, jQuery objects haven't been patched with the appropriate methods -- for example, attr. What am I doing wrong?

@bendangelo
Copy link

I just got this working myself. Make sure chai-jquery is required right after chai.

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

2 participants