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

jasmine-es6

v0.4.3

Published

Helpers and overrides that augment Jasmine for use in an ES6+ environment

Downloads

7,557

Readme

This package has been deprecated in favor of AVA

jasmine-es6

Build Status

Helpers and overrides that augment Jasmine for use in an ES6+ environment

Installing

jasmine-es6 is available as an npm package and is meant to be installed in place of the jasmine package.

Usage

CLI

jasmine-es6 provides a jasmine executable, meant to be used in place of the executable provided by the jasmine package. It runs a project's Jasmine specs in a Babel environment, which transpiles ES6+ code at runtime. jasmine-es6 does not require a jasmine.json to be present; it will fallback to the default jasmine.json that would be generated by running jasmine init. The JASMINE_CONFIG_PATH environment variable is still respected.

When using the CLI, the overrides listed below will be enabled. Note that if a custom jasmine.json is used, the overrides will not be enabled by default. jasmine-es6/lib/install.js must be added as a helper to the custom jasmine.json as follows:

{
  "spec_dir": "spec",
  "spec_files": [
    "**/*[sS]pec.js"
  ],
  "helpers": [
    "../node_modules/jasmine-es6/lib/install.js",
    "helpers/**/*.js"
  ]
}

Overrides

Extend it, beforeEach, etc. with additional behavior. Either install overrides individually (as shown below) or all at once:

import install from 'jasmine-es6';
install();

Async

Adds support for async test cases by transforming them to use Jasmine's done callback. Exceptions thrown by any async function calls are caught and passed to Jasmine's done.fail callback.

import fs from 'fs-promise';
import install from 'jasmine-es6/overrides/async';
install();

describe('Async', function() {
  beforeEach(async function() {
    this.contents = await fs.readFile('./package.json', 'utf8');
  });

  it('supports async-await test cases', async function() {
    const packageJson = JSON.parse(this.contents);
    expect(packageJson.name).toBe('jasmine-es6');
  });
});

Note that with this override installed, test cases will no longer be able to access the done argument.

Helpers

Functions and classes that enable more expressive and concise test cases. Either require helpers individually (as shown below) or all at once:

import {catchError, Promise} from 'jasmine-es6';

catchError

"Returns" the error message (e.message) of an async function call or undefined if no error is thrown.

import catchError from 'jasmine-es6/helpers/catch_error';
import install from 'jasmine-es6/overrides/async';
install();

describe('Async', function() {
  it('enables easy assertion on async errors', async function() {
    const errorMessage = await catchError(fs.readFile('does_not_exist', 'utf8'));
    expect(errorMessage).toMatch(/ENOENT/);
  });
});

Development

Getting Started

The application requires the following external dependencies:

  • Node.js

The rest of the dependencies are handled through:

npm install

Run tests with:

npm test