Reference external libs in buster config?

123 views
Skip to first unread message

Jake Trent

unread,
Jul 26, 2012, 11:36:19 AM7/26/12
to bust...@googlegroups.com
Is it possible to reference an external lib in your buster config?  For instance, I have tests for a widget that at runtime has certain libraries that it depends on, but I don't want to include them locally in my test context.  When I try something like this:

config['browser-all'] = {
libs: [
],
/*...*/
};

And then run 'buster test', I get this error:

Failed loading configuration: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' matched no files or resources

Does anyone know if this is possible?

August Lilleaas

unread,
Jul 26, 2012, 1:19:26 PM7/26/12
to bust...@googlegroups.com
This has been discussed before, in issue 126: https://github.com/busterjs/buster/issues/126

It's something we want to add, but we haven't yet. We also don't consider it critical, as you can see it's assigned to milestone 1.x so it might not make it to 1.0.

The issue explains a workaround by using proxies which we support today (the "backend" property of a resource), but it's a bit cumbersome.

Jake Trent

unread,
Aug 3, 2012, 10:32:08 AM8/3/12
to bust...@googlegroups.com
@August, thanks for pointing out the existence of the resources attribute and the support for "backend" being an external server.  Following the example in the config docs:

config["Browser integration tests"] = { resources: [ { path: "/todo-items", backend: "http://localhost:8000/todo/todo-items" }
};

I still can't seem to make it work.  I've tried many permutations of "backend", "path" and then the reference to a file on a specific backend, to no avail.  Here's one of my guesses on how to reference cdn-hosted jquery:

config["Browser integration tests"] = { resources: [ { path: "googleapis", backend: "https://ajax.googleapis.com/ajax/libs" } ],
sources: [
"googleapis/jquery/1.7.2/jquery.min.js"
};

That when I run "buster test" only yields:

Failed loading configuration: 'googleapis/jquery/1.7.2/jquery.min.js' matched no files or resources

Where am I getting this wrong?

Thanks for your insight.

August Lilleaas

unread,
Aug 3, 2012, 1:34:24 PM8/3/12
to bust...@googlegroups.com
Doh, forgot that buster will look in the file system for stuff you put in "sources".

For now, the only way is to manually load it in your tests. Kind of shitty, but it will at least work. You can get the actual path with buster.env.contextPath +"/googleapis/jquery/1.7.2/jquery.min.js", and then you need to manually create a script tag, and... Yeah.

Or you could add it to the test bed. Haven't tested this, but it should work.

{
    resources: [
        {path: "/", content: "<!DOCTYPE html><html><head><script src='googleapis/jquery/1.7.2/jquery.min.js'>{{scripts}}</head><body></body></html>"}
    ]
}

{{scripts}} is where the the config file scripts will be loaded. Make sure you use a relative path for the src attribute.
Reply all
Reply to author
Forward
0 new messages