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-angularity-solution

v1.2.1

Published

Requisite configuration and modules to test Angularity projects with Karma

Downloads

3

Readme

Karma Angularity Solution

Requisite configuration and modules to test Angularity projects with Karma

Angularity

Angularity is an opinionated project structure for building applications in AngularJS.

This project is for use with the Webpack implementation, and is not suitable for the original Browserify-Sass Angularity implementation.

Rationale

The original Browserify-Sass Angularity was a global installation that included the Karma unit testing framework. This is not the case with the new Webpack implementation.

Use this package, along with the Webpack Angularity implementation, to unit tests Angularity projects.

Limitations

  • This package is not a global installation. You need to install as a development dependency in every single project you wish to build.

  • This package does not contain Karma, you will need to install separately (see below).

  • This package presumes npm scripts. If you want to run outside of scripts you will need some additional global installs (see below).

  • Favours Teamcity CI server, to the extent that it includes its reporter.

Installation

Do not follow the Angularity installation instructions.

Continue to use a Node version manager such as nvm for Mac, or nvm-windows for Windows. However you can run on NodeJS 4.0.0, meaning:

nvm install 4.0.0
nvm use 4.0.0

And additionally on Mac you may wish to set your default Node version:

nvm alias default 4.0.0

Now install this package as a local dev-dependency.

npm install --save-dev karma-angularity-solution

Co-requisites

Install webpack-angularity-solution as a local dev-dependency in order to build the test bundle.

npm install --save-dev webpack-angularity-solution

Note that you do not need any global installs if you only use npm scripts. But if you operate outside of npm scripts you will find that you are missing Karma, and cross-env as global installs.

Each project

package.json

Use the following dev-dependencies and scripts in your project.

{
  "scripts": {
    "test": "cross-env MODE=test webpack -d --progress && karma start",
    "ci": "cross-env KARMA_REPORTER=teamcity MODE=test webpack -d --progress && karma start"
  },
  "devDependencies": {
    "webpack-angularity-solution": "latest"
    "karma-angularity-solution": "latest"
  }
}

Some explanation:

  • cross-env

    Any setting passed to cross-env corresponds to environment variables. By convention they are UPPERCASE. These environment variables are private to the executable that follows so you don't need to worry about name conflicts across different projects.

karma.conf.js

Create a Karma configuration file that delegates to the karma-angularity-solution package. Use options taken from the same environment variables used in your package.json scripts.

/* global process:true */

module.exports = require('karma-angularity-solution')(process.env);

Some explanation:

  • Options by process.env

    This process.env may be passed in entirety. The solution will automatically convert any upper-case option SOME_OPTION to camel-case someOption and parse strings to the correct type. Note however that Array parsing is not supported.

Usage

Run the scripts that are defined in your package.json by using npm run ....

For example:

  • run unit tests using npm run test

  • run with the TeamCity reporter using npm run ci

Options

  • port:int Optional port (that overrides angularity.json)

  • reporter:string Optional reporter name, or Array thereof (defaults to "spec")

  • browser:string Optional browser, or Array thereof (defaults to "Chrome")

  • logLevel:string Optional log-level (defaults to "LOG_INFO").

    Legal values include "LOG_DISABLE"|"LOG_ERROR"|"LOG_WARN"|"LOG_INDO"|"LOG_DEBUG".

Environment variables

All settings may be parsed from uppercase environment variables. For example, to suppress logging during the test:

{
  "scripts": {
    "silent": "cross-env LOG_LEVEL=LOG_DISABLE MODE=test webpack -d --progress && karma start"
	...
  }
}