1.2.1 • Published 6 years ago

metadata-regression-testing v1.2.1

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

Simple HTML Metadata Regression Testing Tool Usage | API | CLI | Reporter

Build Status Coverage Status XO code style FOSSA Status semantic-release

Useful for when you want to ensure that metadata remains the same for a certain page.

HTML metadata is important and this tool aims to help ensure that existing metadata remains the same throughout different scenarios where its data can be removed or edited. Since viewing page source can be such an eye swore and there is the chance of you missing the small details. MRT (metadata-regression-testing) will scrape your metadata and show the difference if any is found overtime.

Install

$ npm install --save metadata-regression-testing

Usage

const { mrt } = require('metadata-regression-testing');
const opts = {};

mrt(opts, 'https://github.com').then(isExpected => {
    console.log(isExpected)
    //=> true
    //   See ./tests/metadata-regression/expected/_homepage.json
});

opts.path = 'tests/updated';
opts.keysOnly = true;

mrt(opts, 'https://www.google.com', 'https://github.com').then(isExpected => {
    console.log(isExpected)
    //=> false
    //   See ./tests/updated/diffs/www.google.com_VS_github.com_homepage.json
    //   Check console for differences between google and github metadata keys (example only)
});

Note: Files are generated in the following folder structure vy default (override is possible).

project_folder
|_ tests/
    |_metadata-regression/
        |_actual/
        |   *.json
        |_diffs/
        |   *.txt
        |_expected/
            *.json

API

mrt(opts, testUrl, refUrl) ⇒ Boolean

Scrapes given URL/s for HTML metadata and performs a regression test

Returns: Boolean - whether or not a match was found

ParamTypeDefaultDescription
optsObjectJSON object with desired options
opts.pathString'tests/metadata-regression'If defined, data files will be stored at dir
opts.keysOnlyBooleanfalseIf set to true, values will not be asserted
testUrlStringWeb page endpoint to scrape metadata from and test
refUrlStringWeb page endpoint to use as reference for the metadata

CLI

$   npm install metadata-regression-testing -g
$   mrt --help

    Usage
        $ mrt <testUrl> [refUrl]

        Options
        --keys-only, -k   Only compare keys in metadata object
        --diff-board, -b  Generates an HTML report to view results
        --path, -p        Defines where the data/results should be stored


        Examples
        $ mrt https://mrtoverflow.com
        
        $ mrt https://mrtoverflow.com --keys-only
        
        $ mrt https://qa-mrtoverflow.com https://dev-mrtoverflow.com
        
        $ mrt https://qa-mrtoverflow.com https://dev-mrtoverflow.com --keys-only

Console examples

First Run Terminal Output

Reporter

Diffboard is a HTML report that helps to visualize tests so issues can be easily spotted outside of the console.

Features

  • Diff highlighting
  • Hide/Show unwanted tabs for falied tests
  • Different view types for failed tests
  • Filters/Search to only display the tests you want
  • Offline viewing

This reporter is best used in the after hook of the test runner. The path to the reporter will be printed in the console.

Available Options

ParamTypeDefaultDescription
optionsObject
options.diffboardTitleString'Diffboard'The name that will be displayed in the header
options.pathStringMRT defualt pathDir of results created by MRT
options.filenameString'diffboard'Filename of saved report Applies to the generated html and json files.

Tests

npm test

Additional Info

This is not a test runner, it only returns a value that can be asserted within a test runner of your choice (ava, mocha, etc.).

It automatically creates an expected JSON on the first run of any URL. These JSON files are named based on the URL path after the domain. A _homepage file is created from the homepage whether or not / is added to the domain.

Review html-metadata to see what is being scrapped.

License

FOSSA Status

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago