npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metadata-regression-testing

v1.2.1

Published

🔄 Metadata Regression Testing Tool 🔄

Downloads

13

Readme

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

| Param | Type | Default | Description | | --- | --- | --- | --- | | opts | Object | | JSON object with desired options | | [opts.path] | String | 'tests/metadata-regression' | If defined, data files will be stored at dir | | [opts.keysOnly] | Boolean | false | If set to true, values will not be asserted | | testUrl | String | | Web page endpoint to scrape metadata from and test | | [refUrl] | String | | Web 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

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | | | [options.diffboardTitle] | String | 'Diffboard' | The name that will be displayed in the header | | [options.path] | String | MRT defualt path | Dir of results created by MRT | | [options.filename] | String | '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