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-parcel

v0.7.3

Published

Parcel tests to Karma

Downloads

33

Readme

Karma Parcel

Use parcel v2 to preprocess karma tests

Notice: v0.7 or newer of this plugin supports parcel@2 and karma@6. If for whatever reason you need to make use of parcel-bundler@1 (or parcel@1), please use [email protected]

Install

To get all the needed packages:

npm i karma parcel karma-parcel -D

Configure:

Add parcel to the frameworks to be used and to the files that should be preprocessed with it:

module.exports = function (config) {
  config.set({
    frameworks: ["mocha", "parcel"],

    // add patterns with all your tests even if they should not
    // be handled by parcel
    files: [
      "tests/**/*.js",
      {
        // parcel tests should not be watched. Parcel will do the
        // watching instead
        pattern: "parcel/**/*.js",
        watched: false,
        included: false,
      },
    ],

    // let karma know which of the test files should be bundled
    // with parcel
    preprocessors: {
      "parcel/*": ["parcel"],
    },
  });
};

parcelConfig

some more parcel specific configuration can be passed to the underlying parcel instance via the parcelConfig attribute of your karma configuration:

module.exports = function (config) {
  config.set({
    // lot of karma configuration
    parcelConfig: {
      cacheDir: "/path/to/cache", // default: "./.cache"
      detailedReport: true, // default: false,
      logLevel: "verbose",
    },
  });
};

karmaParcelWorkspace

make use of this in order to define a workspace other than current directory:

module.exports = function (config) {
  config.set({
    // ... lot of karma configuration
    // use /tmp/foo/bar as the workspace
    karmaParcelWorkspace: path.join(os.tmpdir(), "foo", "bar"),
    parcelConfig: { /* the parcel config*/ },
  });
};

Under the hood

Parcel will create one bundle with all the files that are preprocessed with the parcel preprocessor. The preprocessor will emit an empty file instead of the actual content. The plugin will register a bundle file to karma's fileList with serve: false in order not to be handled by karma's middleware. To serve the bundled file, parcel's own middleware is registered and used

Related

This plugin is heavily inspired by karma-browserify and karma-webpack.