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

@vettvangur/testing

v0.0.28

Published

Testing.

Readme

vettvangur-testing

Testing.

We test the most critical parts of out applications. That means:

  • Fetches
  • Uptime
  • etc.

Example

This example is from the recaptcha test.

// recaptcha.test.ts
import recaptcha from './recaptcha'

describe('recaptcha module', () => {
  // Override the global grecaptcha for our tests
  beforeEach(() => {
    global.grecaptcha = {
      getResponse: jest.fn(),
    }
  })

  describe('validate', () => {
    it('should return false when grecaptcha.getResponse returns an empty string', () => {
      ;(global.grecaptcha.getResponse as jest.Mock).mockReturnValue('')
      expect(recaptcha.validate()).toBe(false)
    })

    it('should return true when grecaptcha.getResponse returns a non-empty string', () => {
      ;(global.grecaptcha.getResponse as jest.Mock).mockReturnValue('non-empty')
      expect(recaptcha.validate()).toBe(true)
    })
  })

  describe('handleError', () => {
    let event: Event
    let preventDefaultSpy: jest.Mock
    let element: HTMLElement

    beforeEach(() => {
      // Create a dummy event and spy on preventDefault
      event = new Event('dummy', { bubbles: true, cancelable: true })
      preventDefaultSpy = jest.fn()
      event.preventDefault = preventDefaultSpy

      // Create a dummy element without any classes
      element = document.createElement('div')
      element.className = ''
    })

    it('should call event.preventDefault and remove "hide" class when validate returns false', () => {
      // Set grecaptcha.getResponse to return empty, so validate() is false.
      ;(global.grecaptcha.getResponse as jest.Mock).mockReturnValue('')

      // Initially, element does not have "hide"
      expect(element.classList.contains('hide')).toBe(false)

      recaptcha.handleError(event, element)

      // The handler should first add "hide", then remove it because validate() is false.
      expect(preventDefaultSpy).toHaveBeenCalled()
      expect(element.classList.contains('hide')).toBe(false)
    })

    it('should add "hide" class and not call preventDefault when validate returns true', () => {
      // Set grecaptcha.getResponse to return non-empty, so validate() is true.
      ;(global.grecaptcha.getResponse as jest.Mock).mockReturnValue('non-empty')

      expect(element.classList.contains('hide')).toBe(false)

      recaptcha.handleError(event, element)

      // Since validate() is true, the "hide" class remains and preventDefault is not called.
      expect(preventDefaultSpy).not.toHaveBeenCalled()
      expect(element.classList.contains('hide')).toBe(true)
    })

    it('should not throw if element is null', () => {
      // Even if element is null, handleError should exit without error.
      expect(() => recaptcha.handleError(event, null as unknown as HTMLElement)).not.toThrow()
    })
  })
})