thomasdavis / w3cjs

A npm package for testing files or url's again the wc3 validator
http://thomasdavis.github.com/w3cjs/
The Unlicense
159 stars 25 forks source link

Timeouts #34

Open jlaustill opened 7 years ago

jlaustill commented 7 years ago

First off, this library is great so thanks for making it!

I just wrote a quick set of tests to validate our site, but we have a few pages that always take longer than 2 seconds to load(magento, yuck). anyways, I don't see any way to define a longer timeout. So I dug into your code and found it to be as easy as

var getRequest = function(isLocal, options) {
    var timeout = options.timeout || 2000;
    var req = isLocal ? proxyRequest.post(w3cCheckUrl) : proxyRequest.get(w3cCheckUrl).timeout({response: timeout, deadline: timeout * 30});

and then passing in

        w3cjs.validate({
        file: environment.server + '/apparel/',
    timeout: 20000,

Is this something you would be willing to accept a PR for? If so, how would you go about implementing it? This works and keeps the default basically the same as the defaults for the request library. I don't find the 'response' and 'deadline' verbage useful or meaningful at all, so I just used timeout and computed it to match the defaults. I'd be happy to handle it a better way however :)