Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Loading external sources with the "resources" proxy #126

Open
jkarsrud opened this Issue · 2 comments

3 participants

@jkarsrud

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!

@augustl
Owner

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

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
Something went wrong with that request. Please try again.