GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — NodeJS module

NodeJS module

Jump to bottom Edit New page
Chewie edited this page Feb 28, 2022 · 17 revisions

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.

Requirements

  • 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

Add the module inside your NodeJS project

npm install yellowlabtools --save

Example

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);
        
    });

Options

You can launch the test with options:

var yltOptions = {
    device: 'mobile',
    screenshot: '/my/path/screenshot.png'
};

ylt(urlToTest, yltOptions)
    .then(function(data) { });
device [String]

Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size). Default is "desktop".

screenshot [String or false]

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).

cookie [String]

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.

authUser [String] & authPass [String]

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.

Result

The data attribute provided in the .then() is the entire JSON response.
See the JSON output format here.

Debugging

See the page How do I debug Yellow Lab Tools?

"An API is only as good as its documentation." Please help me improving this documentation by telling me whatever's not clearly explained.

Add a custom sidebar

Clone this wiki locally

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.