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

karma-ava

v0.0.1

Published

Karma plugin for AVA

Downloads

11

Readme

karma-ava Build Status

Run AVA tests with karma

WARNING: Alpha level software - for evaluation use only

Install

Note: this currently requires a custom build of AVA

$ npm install --save-dev jamestalmage/ava#karma-ava karma karma-ava karma-chrome-launcher

Usage

Create a karma.conf.js, like so:

module.exports = function(config) {
  config.set({
    frameworks: ['ava'],
    files: [
      'test/*.js'
    ],
    browsers: ['Chrome']
  });
};

Then run karma start:

$ node_modules/.bin/karma start

Notes

  • Be careful not to include test helpers in the files pattern (future improvements will automatically filter helpers out).

How it works

  1. The ava preprocessor (lib/preprocessor.js) bundles up a single test. Instead of returning the bundle result. It stores it at node_modules/.cache/karma-ava/<UNIQUE-HASH>.js. Karma sees a one-liner function call as the result:
window.__AVA__.addFile(AVA_HASH, TEST_HASH, TEST_PREFIX);
  • AVA_HASH is the cache key for the external bundle of AVA common to all tests. It just contains AVA and it's dependencies.

  • TEST_HASH is the cache key for the individual test bundle.

  • TEST_PREFIX is a string prefix to put before the test title, something like: "dirname > filename > ".

  1. The ava middleware provides two routes:
  • /karma-ava/<CACHE_KEY>.js - returns the the bundle stored for that cache key (could be individual test bundles or the common AVA bundle).

  • /karma-ava/child/:avaHash/:testHash - returns an html page that simply loads two bundles (the common bundle, and the individual test bundle). These pages will be loaded into iframes by the main process.

  1. lib/main.js
  • This is loaded in the main window by the framework. It provides the window.__AVA__.addFile() method discussed above, and acts as a test runner for individual iFrames. It also communicates test results back to the Karma server in a format it understands.

TODO's

  • Create opinionated, configuration-free defaults that follow AVA's current style.

  • Give the user greater control over what goes in the external/common bundle.

  • Automatically ignore test helpers

  • Create a custom karma reporter that uses AVA's own loggers

  • Honor ava config params from package.json

  • Allow for custom babel configs

  • Use watchify for faster rebuilds and smart, dependency-based rerun behavior.

License

MIT © James Talmage