podefr / jasmine-reqjs-jstd

This is a simple project that explains how to run Jasmine BDD specs over modules loaded with require.js, in three different environments: JsTestDriver, Node.js, Web browser
35 stars 3 forks source link

Doesn't work without module names. #1

Open nicolasguenther opened 12 years ago

nicolasguenther commented 12 years ago

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.

podefr commented 12 years ago

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!

quannguyen81 commented 11 years ago

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:

test:

serve:


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!