busterjs/buster — Issue #16: Facilitate relative resource paths
Author: augustl
Created: 2011-12-08 16:05:48+00:00
State: open

When testing with RequireJS, you typically use relative requires:

require(["lib/my-thing"], function () {
....
});

The URL of the page the tests are in is /sessions/[uuid]/resources/, causing RequireJS to attempt to load /sessions/[uuid]/resources/lib/my-thing.js. Buster however provides the file as /sessions/[uuid]/resources/absolute/path/to/lib/my-thing.js.

Possible solutions:

# Use the relative paths when running tests, instead of absolute paths.
# Provide a context path, so one can do something like `require([buster.contextPath + "/lib/my-thing"])`.

The latter is an option - typically when testing RequireJS apps you don't put "sources" or "deps" in your config file, just "tests", since you require the relevant implementation code in the tests themselves, nodejs style.