-
-
Notifications
You must be signed in to change notification settings - Fork 121
NodeJS module
Yellow Lab Tools is build around a core, which is a NodeJS module. The server uses the core, the CLI uses the core, and you can use if also if none of them fits your needs.
Don't hesitate to contact us before coding something around YLT, your need could be the need of the many. So adding the functionality directly into YLT would probably be great.
- NodeJS > 4.0
- Make sure you have the requirements listed here: https://github.com/nodejs/node-gyp#installation
- On Linux, you also need libjpeg and fontconfig:
sudo apt-get install libjpeg-dev libfontconfig
npm install yellowlabtools --save
The core returns a promise you can use this way:
var ylt = require('../lib/index');
ylt(urlToTest)
.then(function(data) {
console.log('Success');
console.log(JSON.stringify(data, null, 2));
})
.fail(function(err) {
console.log('Test failed for url: ' + url);
console.error(err);
});
You can launch the test with options:
var yltOptions = {
device: 'mobile',
screenshot: '/my/path/screenshot.png'
};
ylt(urlToTest, yltOptions)
.then(function(data) { });
Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size). Default is "desktop".
The path where you want the screenshot to be saved (or false if you don't want a screenshot).
The file will be a large PNG file (unlike the public API option that only stores a small JPG thumbnail).
Adds a cookie for a domain. Multiple cookies can be set, using a pipe separator. Example: bar1=foo1;domain=.domain1.com|bar2=foo2;domain=www.domain2.com
.
Username and password for basic HTTP authentication. If your authentication is not basic (form based), you might be able to copy the session cookie from your browser, paste it in the "Cookie" setting and launch a run before your cookie expires.
The data
attribute provided in the .then()
is the entire JSON response.
See the JSON output format here.
See the page How do I debug Yellow Lab Tools?