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 🙏

© 2024 – Pkg Stats / Ryan Hefner

corvid-tests

v2.6.7

Published

corvid-tests is a lightweight test package for corvid&js development

Downloads

17

Readme

corvid-tests

this package is still in development -updated documentation will be added soon too

corvid-tests is a lighweight package for making simple programmatic tests without the cli.

making synchronous tests with testsuite class! (testsuite tests & before function & after functions should be synchronous)

import { TestSuite } from 'corvid-tests';
function tests(){
    const ts = new TestSuite('my first test suite!');
    ts.addTest('should be truthy').expect([2]).toBeTruthy();
    ts.addTest('deep object comparison should work').expect([1,2,3]).deepObjectEquals([1,2,3]);
    const results = ts.getAllTestsResults();
    console.log('sync test suite results',results)
}


tests()

////////output////////
sync test suite results [
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.406Z,
    m_Passed: true,
    m_TimePassed: 70.1249999999618,
    m_Description: 'should be truthy'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.406Z,
    m_Passed: true,
    m_TimePassed: 139.61499999999205,
    m_Description: 'deep object comparison should work'
  }
]
////////////////

making asynchronous tests with AsyncTestSuite class (tests & before & after functions can be synchronous or asynchronous)

import { AsyncTestSuite } from 'corvid-tests';

async function asyncTests(){
    const ats = new AsyncTestSuite('my first async test suite !');

    ats.addBeforeEach(()=>{'random before each function'});
    ats.addAfterEach(async ()=>{'random after each function'})
    ats.addTest('should contain 2').expect([1,2,3]).toContain(2);
    ats.addTest('should be equal').expect(5).toBe(5);
    ats.addTest('should fail').asyncExpect(async ()=>{
        /// do some async stuff...
        return 5
    }).toBe(2);
    ats.addTest('should fail').asyncExpect(async ()=>{
        throw new Error('i hate errors')
        return 5
    }).toBe(2);
    const results = await ats.getAllTestsResults();
    console.log('async test suite results', results);
    const failed = await ats.getFailedTestsResults();
    console.log('failed',failed);
    const passed = await ats.getPassedTestsResults();
    console.log('passed',passed);
}

////////output////////
async test suite results [
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: true,
    m_TimePassed: 174.11199999997962,
    m_Description: 'should contain 2'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: true,
    m_TimePassed: 172.08299999998644,
    m_Description: 'should be equal'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: false,
    m_TimePassed: 169.41100000002507,
    m_Description: 'should fail',
    m_FailedString: 'expected 5, but got 2'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: false,
    m_TimePassed: 0,
    m_Description: 'should fail',
    m_FailedString: 'test failed',
    m_ErrorDetected: true,
    m_ErrorString: 'i hate errors'
  }
]
failed [
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: false,
    m_TimePassed: 169.41100000002507,
    m_Description: 'should fail',
    m_FailedString: 'expected 5, but got 2'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: false,
    m_TimePassed: 0,
    m_Description: 'should fail',
    m_FailedString: 'test failed',
    m_ErrorDetected: true,
    m_ErrorString: 'i hate errors'
  }
]
passed [
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: true,
    m_TimePassed: 174.11199999997962,
    m_Description: 'should contain 2'
  },
  TestResult {
    m_StartAt: 2020-08-21T16:35:02.413Z,
    m_Passed: true,
    m_TimePassed: 172.08299999998644,
    m_Description: 'should be equal'
  }
]
////////////////