Skip to main content

Class: BrowserInteractionResultReader

A utility entity to read all generated files from the directory holding the data and results from the last browser interaction run

Hierarchy

  • default

    BrowserInteractionResultReader

Methods

cleanup()

clean up data/files generated from the memlab browser interaction run

  • Returns: void | no return value
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// delete all data/files generated by takeSnapshots
result.cleanup();
})();

getInteractionSteps()

browser interaction step sequence

  • Returns: E2EStepInfo[] | an array of browser interaction step information
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

const steps = result.getInteractionSteps();
// print each browser interaction's name and JavaScript heap size (in bytes)
steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))
})();

getRootDirectory()

get the directory where the data and generated files of the memlab run were stored

  • Returns: string | absolute path of the directory
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get the directory that stores all the files
// generated from the takeSnapshots call
const dataDir = result.getRootDirectory();
})();

getRunMetaInfo()

general meta data of the browser interaction run

  • Returns: RunMetaInfo | meta data about the entire browser interaction
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

const metaInfo = result.getRunMetaInfo();
// print all browser web console output
console.log(metaInfo.browserInfo._consoleMessages.join('\n'));
})();

getSnapshotFileDir()

get the directory holding all snapshot files

  • Returns: string | the absolute path of the directory
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get the absolute path the directory holding all snapshot files
const files = result.getSnapshotFileDir();
})();

getSnapshotFiles()

get all snapshot files generated from last memlab browser interaction

  • Returns: string[] | an array of snapshot file's absolute path
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get absolute paths of all snapshot files
const files = result.getSnapshotFiles();
})();

Static from(workDir?)

build a result reader from a data directory where the data and generated files of a memlab run were stored

const {BrowserInteractionResultReader} = require('@memlab/api');

const dataDir = '/tmp/memlab'; // where the last memlab run stores results
const reader = BrowserInteractionResultReader.from(dataDir);
reader.cleanup(); // clean up the results
  • Hierarchy
  • Methods
    • cleanup()
    • getInteractionSteps()
    • getRootDirectory()
    • getRunMetaInfo()
    • getSnapshotFileDir()
    • getSnapshotFiles()
    • Static from(workDir?)