Serving additional resources with glob with buster server

47 views
Skip to first unread message

Ryan Schmidt

unread,
Mar 1, 2012, 1:21:19 AM3/1/12
to bust...@googlegroups.com
Hello. In my tests, running in browsers using buster server, I want to access some png files that are in my test folder. From the docs I gather that I need to add a resources section to my buster.js config file:

http://busterjs.org/docs/configuration/#properties

It says "A resource can be a string, i.e. a glob pattern/file name, or an object." But I was unable to locate a glob example. My rootPath is '../' and my tests are currently ['test/*test.js']. So what would I need to add to serve all test/*.png files? And then, under what URL do I then access them in my tests? The docs say I use buster.env.path; would it just be buster.env.path + '/foo.png' or would it be buster.env.path + '/test/foo.png' or something else?

Thanks.


Christian Johansen

unread,
Mar 1, 2012, 1:47:46 AM3/1/12
to bust...@googlegroups.com
Hi,

You can serve the images by using the glob you used in this email :) Resources are resolved from the root path, so your config would include this:

rootPath: "../",
resources: ["test/*.png"]

Then, like you guessed, in the tests you can reach these images by using

buster.env.path + "/test/foo.png"

Let me know if you have any problems using this.

Christian
--
MVH
Christian

Ryan Schmidt

unread,
Mar 2, 2012, 4:58:10 PM3/2/12
to bust...@googlegroups.com
On Mar 1, 2012, at 00:47, Christian Johansen wrote:

> You can serve the images by using the glob you used in this email :) Resources are resolved from the root path, so your config would include this:
>
> rootPath: "../",
> resources: ["test/*.png"]
>
> Then, like you guessed, in the tests you can reach these images by using
>
> buster.env.path + "/test/foo.png"

Thank you; I was making this harder than it needed to be. It's working fine.

I think I learn best by example, so for others like me, it might help if you had an example in your documentation showing, say, how all of the *.css files in a directory could be loaded and served as resources.

Christian Johansen

unread,
Mar 6, 2012, 1:53:50 AM3/6/12
to bust...@googlegroups.com

Definitely. Care to take a stab at the example? http://github.com/busterjs/buster-docs :)

Reply all
Reply to author
Forward
0 new messages