Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uvu

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uvu

uvu is an extremely fast and lightweight test runner for Node.js and the browser

  • 0.5.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
decreased by-15.6%
Maintainers
1
Weekly downloads
 
Created

What is uvu?

The uvu npm package is a highly performant and lightweight test runner/framework for JavaScript, designed to execute tests quickly and support both Node.js and browser environments. It provides a simple API for defining and running tests, as well as assertions to validate code.

What are uvu's main functionalities?

Test Definition and Execution

This feature allows you to define and run tests. The code sample demonstrates how to define a simple test suite with uvu to test the Math.sqrt function.

const { test } = require('uvu');
const assert = require('uvu/assert');

test('Math.sqrt()', () => {
  assert.is(Math.sqrt(4), 2);
  assert.is(Math.sqrt(144), 12);
  assert.is(Math.sqrt(2), Math.SQRT2);
});

test.run();

Asynchronous Test Support

uvu supports asynchronous tests, allowing you to test asynchronous operations like fetching data from an API. The code sample shows an asynchronous test that awaits the resolution of a fetchData function.

const { test } = require('uvu');
const assert = require('uvu/assert');

test('async test', async () => {
  const data = await fetchData();
  assert.is(data, expectedData);
});

test.run();

Hooks

uvu provides hooks like before, after, before.each, and after.each to set up preconditions and clean up after tests. The code sample illustrates how to use before.each and after.each hooks in a test suite.

const { test, suite } = require('uvu');
const assert = require('uvu/assert');

const mathSuite = suite('math');

mathSuite.before.each(() => {
  // setup code before each test
});

mathSuite.after.each(() => {
  // cleanup code after each test
});

mathSuite('Math.pow()', () => {
  assert.is(Math.pow(2, 3), 8);
});

mathSuite.run();

Other packages similar to uvu

Keywords

FAQs

Package last updated on 03 Jul 2022

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