jasmine-reqjs-jstd icon indicating copy to clipboard operation
jasmine-reqjs-jstd copied to clipboard

Doesn't work without module names.

Open nicolasguenther opened this issue 12 years ago • 2 comments

Thanks for your example, it works fine as-is. Do you know why it is necessary to specify names for the modules under test? It seems not to work with requires autogenerated names.

nicolasguenther avatar Apr 27 '12 08:04 nicolasguenther

That's the whole point of making jstd work with require.js modules. You have to:

Name the modules Load them prior to running the tests Wrap your tests into other modules.

I'm using this solution for test driven development, but if you don't care about TDD and just want to execute the tests in continuous integration, you could imagine removing the names and running the optimizer against your modules + tests

Didn't try the solution though!

podefr avatar Apr 27 '12 09:04 podefr

Do you know if it is possible to define dependencies within your test module (i.e. spec file)?

Something like:

require(["HelloWorld"], function (HelloWorld) { var ADependency = require("ADependency"); describe("HelloWorldTest", function () { it("should return hello world!", function () { expect(HelloWorld()).toEqual("hello world!"); }); }); });

OR: require(["HelloWorld", "ADependency"], function (HelloWorld, ADependency) {...}

Where,

define("ADependency", function () {

return function () { return "I am a dependency!"; };

});

*** Configuration ***

server: http://localhost:9876

load:

  • src-test/libs/mocha.js
  • src-test/libs/chai.js
  • src-test/libs/MochaAdapter.js
  • libs/require.js
  • src-test/config.js
  • src/ADependency.js
  • src/HelloWorld.js

test:

  • src-test/HelloWorld-spec.js

serve:

  • src-test/libs/mocha.js
  • src-test/libs/chai.js
  • libs/jquery.js
  • libs/require.js
  • src-test/config.js

So far, it looks like it doesn't like the dependency declared like that.

I am using Mocha + Chai for BDD and assertion. Could you please help me understand if this is possible or if I missed anything in my setup?

Thank you very much!

quannguyen81 avatar Jan 11 '13 00:01 quannguyen81