Ghost Inspector API for Node.js
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
test
.eslintrc.json
.gitignore
.npmignore
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

Ghost Inspector Node.js Bindings

Circle CI

Node.js module for interacting with Ghost Inspector's API.

Installing with npm

npm install ghost-inspector

Usage

Every method is accessed via your GhostInspector instance. Your API Key is passed in when the instance is created:

const GhostInspector = require('ghost-inspector')('[api-key]');

getSuites([callback])

Fetch an array of all the suites in your account.

GhostInspector.getSuites(function (err, suites) {
    if (err) return console.log('Error: ' + err);
    console.log(suites);
});

getSuite(suiteId, [callback])

Fetch a single suite from your account.

GhostInspector.getSuite('[suite-id]', function (err, suite) {
    if (err) return console.log('Error: ' + err);
    console.log(suite);
});

getSuiteTests(suiteId, [callback])

Fetch an array of all the tests in a suite.

GhostInspector.getSuiteTests('[suite-id]', function (err, tests) {
    if (err) return console.log('Error: ' + err);
    console.log(tests);
});

getSuiteResults(suiteId, [options], [callback])

Fetch an array of suite results for a suite.

const options = {
    count: 10,
    offset: 0
};

GhostInspector.getSuiteResults('[suite-id]', options, function (err, results) {
    if (err) return console.log('Error: ' + err);
    console.log(results);
});

executeSuite(suiteId, [options], [callback])

Execute all the tests in a suite and returns an array of results.

// Optionally override the start URL of all tests in this suite (for this run only) 
const options = {
    startUrl: 'http://alternate.yourcompany.com'
};

GhostInspector.executeSuite('[suite-id]', options, function (err, results, passing) {
    if (err) return console.log('Error: ' + err);
    console.log(passing === true ? 'Passed' : 'Failed');
    console.log(results);
});

downloadSuiteSeleniumHtml(suiteId, dest, [callback])

Download a zip file of all tests in Selenium HTML format

GhostInspector.downloadSuiteSeleniumHtml('[suite-id]', 'suite.zip', function (err) {
    if (err) return console.log('Error: ' + err);
    console.log('File saved to suite.zip.');
});

downloadSuiteSeleniumJson(suiteId, dest, [callback])

Download a zip file of all tests in Selenium JSON format

GhostInspector.downloadSuiteSeleniumJson('[suite-id]', 'suite.zip', function (err) {
    if (err) return console.log('Error: ' + err);
    console.log('File saved to suite.zip.');
});

getTests([callback])

Fetch an array of all the tests in your account.

GhostInspector.getTests(function (err, tests) {
    if (err) return console.log('Error: ' + err);
    console.log(tests);
});

getTest(testId, [callback])

Fetch a single test from your account.

GhostInspector.getTest('[test-id]', function (err, test) {
    if (err) return console.log('Error: ' + err);
    console.log(test);
});

getTestResults(testId, [options], [callback])

Fetch an array of test results for a test.

const options = {
    count: 10,
    offset: 0
};

GhostInspector.getTestResults('[test-id]', options, function (err, results) {
    if (err) return console.log('Error: ' + err);
    console.log(results);
});

executeTest(testId, [options], [callback])

Execute a single test in your account and return the result.

// Optionally override the start URL of the test (for this run only) 
const options = {
    startUrl: 'http://alternate.yourcompany.com'
};

GhostInspector.executeTest('[test-id]', options, function (err, results, passing) {
    if (err) return console.log('Error: ' + err);
    console.log(passing === true ? 'Passed' : 'Failed');
    console.log(results);
});

downloadTestSeleniumHtml(testId, dest, [callback])

Download a single test in Selenium HTML format

GhostInspector.downloadTestSeleniumHtml('[test-id]', 'test.html', function (err) {
    if (err) return console.log('Error: ' + err);
    console.log('File saved to test.html.');
});

downloadTestSeleniumJson(testId, dest, [callback])

Download a single test in Selenium JSON format

GhostInspector.downloadTestSeleniumJson('[test-id]', 'test.json', function (err) {
    if (err) return console.log('Error: ' + err);
    console.log('File saved to test.json.');
});

getSuiteResult(resultId, [callback])

Fetch a single suite result.

GhostInspector.getSuiteResult('[result-id]', function (err, result) {
    if (err) return console.log('Error: ' + err);
    console.log(result);
});

getSuiteResultTestResults(resultId, [callback])

Fetch the test results in a single suite result.

GhostInspector.getSuiteResultTestResults('[result-id]', function (err, result) {
    if (err) return console.log('Error: ' + err);
    console.log(result);
});

cancelSuiteResult(resultId, [callback])

Cancel an in-progress suite result.

GhostInspector.cancelSuiteResult('[result-id]', function (err, result) {
    if (err) return console.log('Error: ' + err);
    console.log(result);
});

getResult(resultId, [callback])

Fetch a single test result.

GhostInspector.getResult('[result-id]', function (err, result) {
    if (err) return console.log('Error: ' + err);
    console.log(result);
});

cancelResult(resultId, [callback])

Cancel an in-progress test result.

GhostInspector.cancelResult('[result-id]', function (err, result) {
    if (err) return console.log('Error: ' + err);
    console.log(result);
});