{"id":14216,"library":"uvu","title":"uvu: Fast & Lightweight Test Runner","description":"uvu is an extremely fast and lightweight test runner designed for both Node.js and browser environments, currently stable at version 0.5.6. It features a minimalist API, supporting `async`/`await` tests and native ES Modules. While `uvu` ships with its own optional assertion library (`uvu/assert`), it is entirely compatible with any assertion library that throws standard JavaScript Errors for failures. It differentiates itself by its focus on performance, minimal footprint, and flexibility in choosing assertion methods, making it a strong contender for projects prioritizing speed and small bundle sizes. Releases are typically patch-based, addressing bugs and improving compatibility, with major feature additions occurring less frequently.","status":"active","version":"0.5.6","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/uvu","tags":["javascript","assert","diffs","runner","snapshot","test","typescript"],"install":[{"cmd":"npm install uvu","lang":"bash","label":"npm"},{"cmd":"yarn add uvu","lang":"bash","label":"yarn"},{"cmd":"pnpm add uvu","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"`test` is a named export. ESM is the preferred and modern usage, especially since v0.5.0 introduced native ESM support. Using `require` in a pure ESM context will lead to errors.","wrong":"const test = require('uvu');","symbol":"test","correct":"import { test } from 'uvu';"},{"note":"The `uvu/assert` module exports its assertion methods as a single module object, so use `import * as assert from 'uvu/assert;'` and then access methods like `assert.is()`. Attempting to destructure individual assertion methods directly will fail.","wrong":"import { is, equal } from 'uvu/assert';","symbol":"assert","correct":"import * as assert from 'uvu/assert';"},{"note":"`suite` is a named export for grouping tests. Like `test`, `require('uvu').suite` is the CJS equivalent but generally discouraged in modern setups.","wrong":"import suite from 'uvu';","symbol":"suite","correct":"import { suite } from 'uvu';"}],"quickstart":{"code":"import { test } from 'uvu';\nimport * as assert from 'uvu/assert';\n\ntest('Math.sqrt()', () => {\n  assert.is(Math.sqrt(4), 2);\n  assert.is(Math.sqrt(144), 12);\n  assert.is(Math.sqrt(2), Math.SQRT2);\n});\n\ntest('JSON operations', () => {\n  const input = {\n    foo: 'hello',\n    bar: 'world'\n  };\n\n  const output = JSON.stringify(input);\n\n  // Snapshot assertions require the exact string match\n  assert.snapshot(output, `{\"foo\":\"hello\",\"bar\":\"world\"}`);\n  // Deep equality assertion\n  assert.equal(JSON.parse(output), input, 'JSON parse matches original');\n});\n\ntest.run();\n\n// To run this test file:\n// $ npm install --save-dev uvu\n// $ uvu tests/demo.js","lang":"typescript","description":"This quickstart demonstrates basic test definition with `uvu` and shows how to use its built-in `uvu/assert` module for various assertions, including `is`, `snapshot`, and `equal`."},"warnings":[{"fix":"Review tests that interact with the `suite` context. Ensure any modifications to the context within test handlers are intentional and do not create unintended side effects across tests. If immutability is desired for specific values, clone them explicitly.","message":"The immutability protection on the `context` object, which prevented modification within test handlers, was removed. `uvu` now passes the original `context` object directly to test handlers, allowing for mutations. This might alter behavior for tests that relied on `context` being read-only within a test.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"For new projects, configure `package.json` with `\"type\": \"module\"` and use `import`/`export`. For mixed or older projects, ensure Node.js is recent enough (>=12 for full native ESM support without flags) or use the `-r esm` flag explicitly when running tests.","message":"Native ES Module (ESM) support was introduced, promoting `import` statements. While `uvu` attempts to detect and use ESM, older Node.js versions or CommonJS projects may require the `--require esm` flag (e.g., `node -r esm your-test.js` or `uvu -r esm tests`). Misconfiguration can lead to 'SyntaxError: Cannot use import statement outside a module' or other module resolution issues.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Review tests for `process.exit()` calls within test bodies; these should be removed or mocked if testing exit behavior. Identify and ensure all Promises are properly handled and resolved/rejected within asynchronous tests to prevent unhandled rejections from failing the test suite.","message":"Since v0.5.6, `uvu` explicitly ensures that tests will fail if they include `process.exit` calls or leave unresolved Promises. Previously, such scenarios might have silently passed or exited without indicating a failure, leading to unreliable test results.","severity":"breaking","affected_versions":">=0.5.6"},{"fix":"Always include `test.run();` as the last statement in your test file to initiate the test execution process. For modularized test files that are imported by a runner, ensure the runner handles the execution.","message":"Forgetting to call `test.run()` (or `suite.run()` for named suites) at the end of your test file will result in no tests being executed, as `uvu` queues tests and only executes them when explicitly told to.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.5.6':26 'addit':108 'address':100 'api':31 'assert':47,56,79,113 'async':33 'await':34 'base':99 'browser':20 'bug':101 'bundl':92 'choos':78 'compat':53,104 'contend':85 'current':22 'design':15 'diff':114 'differenti':66 'entir':52 'environ':21 'error':62 'es':38 'extrem':9 'failur':64 'fast':2,10 'featur':28,107 'flexibl':76 'focus':70 'footprint':74 'frequent':111 'improv':103 'javascript':61,112 'less':110 'librari':48,57 'lightweight':3,12 'major':106 'make':81 'method':80 'minim':73 'minimalist':30 'modul':39 'nativ':37 'node.js':18 'occur':109 'option':46 'patch':98 'patch-bas':97 'perform':72 'priorit':88 'project':87 'releas':94 'runner':5,14,115 'ship':42 'size':93 'small':91 'snapshot':116 'speed':89 'stabl':23 'standard':60 'strong':84 'support':32 'test':4,13,35,117 'throw':59 'typescript':118 'typic':96 'uvu':1,6,41 'uvu/assert':49 'version':25","created_at":"2026-04-20T01:58:33.123628+00:00","updated_at":"2026-04-20T01:58:33.123628+00:00","problems":[{"fix":"Ensure your `package.json` has `\"type\": \"module\"` if you intend to write ES Modules, or use the `--require esm` flag with Node.js or `uvu` CLI: `node -r esm your-test.js` or `uvu -r esm tests/`.","cause":"Attempting to use ES module `import` syntax in a Node.js environment configured for CommonJS, or an older Node.js version without native ESM support, without the `--require esm` flag.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"For `test` and `suite`, use named imports: `import { test, suite } from 'uvu';`. For `uvu/assert`, use `import * as assert from 'uvu/assert';` and then call methods like `assert.is()`.","cause":"This usually indicates that `test` or `suite` were incorrectly imported as default exports (`import test from 'uvu'`) rather than named exports (`import { test } from 'uvu'`), or that `uvu/assert` methods are being destructured instead of accessed via the `assert` object.","error":"TypeError: uvu.test is not a function (or similar for suite, assert)"},{"fix":"Add `import * as assert from 'uvu/assert';` at the top of your test file where `assert` is needed.","cause":"The `uvu/assert` module is optional and must be explicitly imported into your test file if you wish to use its assertion methods.","error":"ReferenceError: assert is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"uvu","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/lukeed/uvu","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/uvu","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}