New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mvt

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvt

A minimum viable testing framework, aka a few test helpers, 0 dependencies

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-64.29%
Maintainers
1
Weekly downloads
 
Created
Source

mvt NPM version js-standard-style

A minimum viable testing framework, aka a few test helpers, 0 dependencies

why another testing module

I'm getting tired of Github security alerts on nested dev dependencies, typically from my chosen test framework. The tests I run are typically lite and don't require all the frills provided by the majors. I'm totes fine with nothing more than testing for a truthy value or comparing two values. As with most of my open source this is for me. There are many actually good test frameworks out there, but this is all I need for many circumstances.

what's good about it

  • It's lightweight @ < 100 sloc
  • It has 0 dependencies (same for devDependencies)

this might be for you if

  • Your tests don't require heavy tooling
  • Concurrency doesn't make or break your testing times
  • You know how to coerce tests to fitting truthy or a/b equality checks
  • You're happy to do said coercion in your test file
  • You don't need much control over test output formatting

install

$ npm install --save-dev mvt

api

runTests (message, testCallback[, meta]) - Just a wrapper that takes care to catch anything in it

  • arguments
    • string - Message to display on test start-up
    • function / async function - Run your tests in this to ensure nothing is missed
    • object - If anything fails this object will be printed to stderr

test (description, truthyOrComparison[[, comparison], meta]) - Test against single truthy value or compare two values

  • arguments
    • string - Test description
    • any - Will fail if not truthy OR if doesn't === argument 3
    • any - If not undefined this must === previous argument or will fail
    • object - If failed this object will be printed to stderr (if only passing truthy value the comparison arg must be undefined)
  • returns true if test passed

testAsync (description, asyncCallback[, meta]) - This simply awaits a promise that must resolve truthy

  • arguments
    • String - Test description
    • async function - Async function / promise returning function that must resolve truthy
    • object - If failed this object will be printed to stderr
  • resolves with true if test passed

usage

const { runTests, start, finish, test, testAsync } = require('mvt')

runTests(`Testing my app`, async () => {
  test('Should be truthy', true)

  test('Should be equal', 1, 1)

  await testAsync('Should resolve truthy', async () => Promise.resolve(true))
})

notes

If your test file is called with the --verbose flag it will list all passed tests

It fails fast and hard with process.exit(1)

license

MIT © Andrew Carpenter

Keywords

FAQs

Package last updated on 01 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc