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

@vaju/testeves

v1.1.0

Published

A workaround testing strategy for highly coupled legacy codebase.

Downloads

4

Readme

testeves

Greenkeeper badge

A workaround testing strategy for highly coupled legacy codebase.

Why

Sometimes you need to test some legacy code which is not actually testable. Refactoring the codebase to write testable code may be hard or it doesn't worth.

How

It's important to learn how testeves works. It is a simple concept. You emit events at critical points in the codebase. The test agent will listen for these events and execute expectations.

Install

Requires Node >= 8.

From npm:

npm install @vaju/testeves

From Github Package Registry. (Guide).

(✔ Type definitions included for TypeScript)

Usage

The tests for this repo (inside the /tests dir) is an ideal example.

The code you need to test: foo.js

const { Testeves } = require('@vaju/testeves');
// or
import { Testeves } from '@vaju/testeves';

// create a hook
const hook = new Testeves();

// ... somewhere in the actual codebase we want to test ...

function foo() {
  ['a', 'b', 'c'].forEach(item => {
    // emit events
    hook.emit({ [item]: true });
  });
  // when the flow is complete, call finishProcess().
  return hook.finishProcess();
}

module.exports = { foo, hook };

Then the test file: foo.spec.js

const { foo, hook } = require('./foo');

// Start the observer. Here is where
// the emitted events are stored.
const observer = hook.listen();

// Before running into actual tests, wait for
// the entire flow to complete.
beforeAll(() => {
  // invoke the function.
  foo();
  // hook.isFinished returns a promise, which is
  // resolved when the hook.finishProcess() is called
  // in the testing code.
  return hook.isFinished;
});

describe('testing', () => {
  test('testing a', () => {
    // the observer object stores the emitted
    // events and their values.
    expect(observer.a).toBe(true);
  });
  test('testing b', () => {
    expect(observer.b).toBe(true);
  });
  test('testing c', () => {
    expect(observer.c).toBe(true);
  });
});

Licence

MIT © Vajahath Ahmed