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

kocha

v1.9.1

Published

Modern, simpler Mocha clone, no globals, lint friendly

Downloads

91

Readme

Kocha v1.1.0

CircleCI codecov

Modern, simpler Mocha clone, no globals, lint friendly

Supports node.js >= active LTS.

:cd: Install

npm install kocha --save-dev

Use in node.js

Require describe, it etc from kocha, and write tests as in mocha:

test.js:

const { describe, it } = require('kocha')
const assert = require('assert')

const add = (a, b) => a + b

describe('add', () => {
  it('adds the given numbers', () => {
    const sum = add(12, 13)

    assert(sum === 25)
  })
})

Then run it by kocha command.

./node_modules/.bin/kocha test.js

This outputs the report like the below:

$ ./node_modules/.bin/kocha test.js

add
  ✓ adds the given numbers

  1 passing (4ms)

Use in karma

TBD

APIs

const {
  describe,
  it,
  before,
  beforeEach,
  after,
  afterEach,
  timeout,
  retries
} = require('kocha')

describe(title, callback)

Adds the test suite by the title and callback. In callback function you can add child test suites and/or test cases.

describe.skip(title, callback)

Adds the skipped test suite by the title and callback. The test suites and cases under this suite are all skipped as well.

it(spec, callback)

Adds the skipped test case by the title and callback. callback implements your test case.

it.skip(spec, callback)

Adds the skipped test case by the title and callback.

before(callback)

Adds the before hook to the current suite.

beforeEach(callback)

Adds the beforeEach hook to the current suite.

after(callback)

Adds the after hook to the current suite.

afterEach(callback)

Adds the afterEach hook to the current suite.

timeout(timeout)

Sets the timeout duration to the test cases or the test suites.

retries(n)

Sets the retry count of the test cases or the test suites.

Goals

  • Support BDD mode, Spec reporter of mocha in CommonJS environment.
    • This includes Karma environment with CommonJS bundler (browserify, webpack).

Non-goals

  • Kocha isn't a drop-in replacement of mocha.
  • Kocha doesn't support interfaces other than BDD, like TDD, QUnit, Exports etc
  • Kocha doesn't support standalone mode in browser.
  • Kocha's BDD interface is not identical to Mocha's BDD interface. See the below for details.

Differences from mocha

  • Kocha doesn't have this.timeout(ms) API. Use kocha.timeout(ms) API instead.
  • Kocha doesn't have this.retries(n) API. Use kocha.retries(n) API instead.
  • Kocha doesn't have xdescribe and xit. Instead use describe.skip and it.skip resp.
  • Kocha doesn't have context and specify keyword. Use describe and it resp.

Migration from mocha

For node.js

  1. Use kocha command instead of mocha or _mocha command.
  2. Add const { describe, it, ... } = require('kocha') statement on the top of each mocha test script.
  3. Rewrite xdescribe and xit to describe.skip and it.skip resp. if you have any.
  4. Rewrite this.timeout(N) to kocha.timeout(N) if you have any.
  5. Rewrite this.retries(N) to kocha.retries(N) if you have any.
  6. Rewrite context and specify to describe to it resp. if you have any.
  7. Then your tests should work with kocha.

If the above doesn't work, please file an issue.

For karma

TBD

Name

Kocha (紅茶, pronounced like ko-cha, not like ko-ka) means black tea in Japanese.

License

MIT