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

mnmsplus

v0.0.2

Published

mnms is a custom testing library built from the ground up using pure Javascript

Downloads

18

Readme

README for mnms Javascript Testing Library

Description

  • 'mnms' is a custom testing library built from the ground up using pure Javascript (no Javscript libraries were used)

How to install Type into the terminal: 'npm install mnmsplus'

How to use

  • Require all of your spec and model files in the default 'SpecRunner.html' file that came with your install. Ensure you leave in the default requirements, as this requires in the code needed to run the testing framework
  • Open the 'SpecRunner.html' file. This will run your tests and output the results in your browser

screenshot

How to run tests

The testing framework includes the following structure:

  • 'describe' blocks that your tests will fit within
  • 'it' blocks within your describe blocks, to run individual tests
  • Within your 'it' blocks, you can provide expectations and matchers to define your unit tests

How to use the testing framework including 'expect':

  • Feed in the code you want evaluated within e.g. expect('code to evaluate')
  • Feed in what you expect into your matcher e.g. toEqual('expected result')
describe("1 equals 1", () => {;
  it("expects 1 to equal 1", () => {
    expect(1).toEqual(1);
  });
});

Hooks available:

  • Before each enables you to run a specified set of code for every test within that describe block
describe(".beforeEach", () => {
  beforeEach( () => {
    var a;
    a = 2;
  });

  it("sets the value before the first test", () => {
    expect(a).toEqual(2);
  });

Matchers available:

  • toEqual
it("expects 1 to equal 1", () => {
  expect(1).toEqual(1);
});
  • toContain
it("expects [1, 2, 3] to contain 2", () => {
  expect([1,2,3]).toContain(1);
});
  • not (utility - to be used to reverse a matcher)
it("expects [1,2,3] to not equal [4,5,6]", () => {
  expect([1,2,3]).not(toEqual([4,5,6]));
});

HTML element selections to test front end (e.g. Feature tests)

  • htmlSelectClassFirst
  • Selects the first html element on the page with that class
  • htmlSelectClassId
  • Selects the html element on the page that has that id
  • fillFormText
  • selects text field by id and fills it with provided text
  • clickButton
  • clicks button on page with that id

Example using all feature test elements

describe('fills a form', function() {
 it("Fill in field, click button, expect page to have the content", function(){
     (see *Note - need to add 'visit('/')' using another library)
     fillFormTextById('test-text-field', 'A text field');
     clickButtonById('test-form-button');
     expect(htmlSelectorId('test-form-output-container')).toEqual("A text field");
 });
});
  • *Note: Requires selenium or equivalent library to visit the page you want to test

Spies

Spies can be used to test the number of times a method was called, and the arguments supplied each time.

Example using spies

describe("changeTyre", function() {
  it("calls .changeTyre() twice", function() {
    var servicedTyres = 0
    var car = {
      changeTyre: function(brand) {
        servicedTyres += 1;
      },
      service: function(brand) {
        this.changeTyre(brand);
        this.changeTyre(brand);
      }
    }

    spyOn(plane, "changeTyre")

    plane.service("pirelli");

    expect(spy.numberOfTimesCalled).toEqual(2);
    expect(spy.arrayOfArguments).toContain(["pirelli"]);
  });
});