Giter Site home page Giter Site logo

thbland / xv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from typicode/xv

0.0 1.0 0.0 514 KB

:x: :heavy_check_mark: Close to the metal JavaScript test runner. Super fast and lightweight. Perfect for small and medium projects.

License: Other

Shell 4.17% JavaScript 95.83%

xv's Introduction



xv


Node.js CI

Setting up and maintaining a test framework can sometimes be complex and time consuming. I've created xv to be a test runner that is low maintainance, easy to setup and use.

xv is great for small and medium projects.

Features

  • โšก Super fast ~0.03s
  • ๐Ÿฆ Lighweight <10kB with zero dependencies
  • ๐Ÿ”ฐ Simple no API to learn, zero-config
  • Natively supports ESM

Used in lowdb and steno.

Requires Node v12.20.0+

Please help me build OSS ๐Ÿ‘‰ GitHub Sponsors

Install

npm install xv --save-dev
yarn add xv --dev

Usage

Create a test file src/add.test.js (or src/test.js) and use Node's built-in assert module:

import { strict as assert } from 'assert' // Node <=16
// import { equal } from 'assert/strict'  // Node >=16

export function testAdd() {
  assert.equal(1 + 2, 3)
}

Edit package.json:

{
  "scripts": {
    "test": "xv src"
  }
}

Run your tests:

npm test               # run all test files in ./src
npx xv src/add.test.js # run a single test file

That's all there is to know. ๐Ÿ˜Ž

Early access for Sponsors

For a limited time xv is available to Sponsors only. Once the goal of 70 sponsors is reached (currently 58), I'll release it under MIT for everyone ๐ŸŽ‰

If you like this project and my work, please help me reach this goal by becoming a sponsor. Thank you!

Note: if you're already sponsoring me via husky, feel free to use xv in any type of project.

TypeScript

If you're using TypeScript, compile your .ts and run xv directly on compiled .js files.

Assuming you have the following tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./lib"
  }
}

Edit package.json to exclude test files from being published and run tsc before xv:

{
  "files": [
    "lib",
    // exclude test files
    "!lib/**/*.test.js",
    "!lib/**/test.js"
  ],
  "scripts": {
    "build": "rm -rf lib && tsc",
    "test": "npm run build && xv lib"
  }
}

xv's People

Contributors

typicode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.