Loading external sources with the "resources" proxy #126

Open
jkarsrud opened this Issue Mar 9, 2012 · 2 comments

Comments

Projects
None yet
3 participants

jkarsrud commented Mar 9, 2012

In some cases, you might not want to have a library dependency directly in your project, so you want to load it from a CDN or some other external server.

I tried doing this with the following config, but the script isn't actually loaded, resulting in tests failing because of a missing dependency;

var config = module.exports;

config['Browser tests'] = {
    rootPath: '../',
    env: 'browser',
    resources: [
        {
            path: 'googleapis',
            backend: 'https://ajax.googleapis.com/'
        }
    ],
    sources: [
        'googleapis/ajax/libs/jquery/1.7.1/',
        'src/jquery.someplugin.js'
    ],
    tests: [
        'test/*-test.js'
    ]
};

Do you agree that this is something that Buster should support? I guess it's not a very common use case, as it makes you rely on network in your tests, but it's probably a feature more people than just me will think is great!

Owner

augustl commented Mar 10, 2012

Makes sense, we should support this:

config["Tests"] = {
    libs: ["http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"],
    sources: ["src/*.js"],
    tests: ["tests/*-test.js"]
}

It's trivial to add support for this to resource sets. We alredy implement and default to file:// which is asynchronous, so we'll just need to allow specification of protocol and define behaviour for http://.

cowwoc commented Dec 21, 2012

August posted a nice workaround at https://groups.google.com/d/msg/busterjs/lgiett_Izic/6EHYZAWLzYQJ. Simply add the following to your config:

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

This worked for me under version 0.6.3 Beta 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment