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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@open-xchange/vitest-plugin-extended

v1.5.0

Published

Vitest plugin with additional useful test assertions

Readme

@open-xchange/vitest-plugin-extended

A plugin for Vitest that bundles the package jest-extended with additional useful test matchers.

Installation

The plugin will take care of everything. It will add all test matchers to the expect object, and it will register all type definitions for test scripts written in TypeScript.

  • Install the plugin as development dependency:

    npm install -D @open-xchange/vitest-plugin-extended
    # or
    pnpm add -D @open-xchange/vitest-plugin-extended
    # or
    yarn add -D @open-xchange/vitest-plugin-extended
  • Create a setup script for Vitest (if not already existing, file name and path do not matter), and import the package:

    // test/setup.ts
    import '@open-xchange/vitest-plugin-extended'
  • Register the setup script in the Vitest configuration:

    // vitest.config.ts
    import { defineConfig } from 'vitest/config'
    
    export default defineConfig({
      test: {
        globals: true,
        setupFiles: ['./test/setup.ts'],
      },
    })

That's it. The matchers can be used in test scripts:

// test/simple.test.ts
it('should work', () => {
  expect(true).toBeTrue()   // from 'jest-extended'
  expect([]).toBeIterable() // extra matchers from this plugin
})

Matchers

toBeInteger

Asserts that the received value is a safe integer.

expect(0).toBeInteger()
expect(-1e10).toBeInteger()
expect(Number.MAX_SAFE_INTEGER).toBeInteger()

expect(Number.MAX_SAFE_INTEGER + 1).not.toBeInteger()
expect(0.5).not.toBeInteger()
expect('0').not.toBeInteger()

toBeAlmost

Asserts that a floating-point number is almost equal to an expected number, with a relative error less than or equal to 2-51 which is twice the number of Number.EPSILON. If the number is expected to be zero, this method will check the absolute value of the received number instead of the relative error.

expect(Math.sin(Math.PI/2)).not.toBe(1)   // not exactly 1
expect(Math.sin(Math.PI/2)).toBeAlmost(1)

expect(Math.sin(Math.PI)).not.toBe(0)     // not exactly 0
expect(Math.sin(Math.PI)).toBeAlmost(0)

toStringifyTo

Asserts whether the tested value, converted to a string, equals the expectation.

expect([1, 2]).toStringifyTo('1,2')
expect({ toString: () => 42 }).toStringifyTo('42')

toThrowValue

Asserts whether the tested function will throw an exception with the exact value. The value does not need to be an instance of class Error.

function throws() { throw 42 }
expect(throws).toThrowValue(42)

toBeIterable

Asserts that a value is an iterable object (it responds to the well-known symbol @@iterator). The method will not be called.

expect([]).toBeIterable()
expect([].values()).toBeIterable()
expect('').toBeIterable()
expect({}).not.toBeIterable()

toBeIterator

Asserts that a value is an iterator object (it responds to next). The method will not be called.

expect([].values()).toBeIterator()
expect([]).not.toBeIterator()
expect({}).not.toBeIterator()

toHaveBeenCalledOn

Asserts that a mock function was called at least once with the specified calling context.

const spy = vi.fn()
spy.call(window)
spy.call(document)
expect(spy).toHaveBeenCalledOn(window)
expect(spy).not.toHaveBeenCalledOn(null)

toHaveBeenAlwaysCalledOn

Asserts that a mock function was always called with the specified calling context.

const spy = vi.fn()
spy.call(window)
spy.call(window)
expect(spy).toHaveBeenAlwaysCalledOn(window)
spy.call(document)
expect(spy).not.toHaveBeenAlwaysCalledOn(window)

toHaveAllBeenCalledTimes

Asserts that the call counts of all mock functions match the specified call counts.

const spies = [vi.fn(), vi.fn(), vi.fn()]
spies[1]()
spies[0]()
spies[1]()
expect(spies).toHaveAllBeenCalledTimes(1, 2, 0)

toHaveAllBeenCalledInOrder

Asserts that the the call order of the mock functions matches the specified call order.

const spies = [vi.fn(), vi.fn(), vi.fn()]
spies[2]()
spies[0]()
spies[1]()
expect(spies).toHaveAllBeenCalledInOrder(2, 0, 1)

toHaveDescendants

Asserts that a DOM element contains at least one descendant element that will be selected by a query string.

expect(document.body).toHaveDescendants('.my-element')