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

titanium-karma-client

v0.2.6

Published

Karma test runner client for Titanium

Downloads

80

Readme

Karma client for Titanium

Greenkeeper badge

Axway Titanium version of the Karma client

Installation

npm i titanium-karma-client -S

Usage

:bulb: If you just want to run unit tests consider using the karma-titanium-launcher wich makes use of this package and does all the required setup for you to test your projects.

This client connects to a Karma server, loads all required files including the testing framework and individual unit tests, executes the tests and then reports the results back to the Karma server. This client is heavily inspired by the default Karma Web client that is used for Browser testing and was adapted to work inside Titanium.

You create a client by instantiating KarmaClient, passing it the URL it should connect to. After that you do the actual connect and can optionally bind a few events to listen for status changes.

import KarmaClient from 'titanium-karma-client';
const client = new KarmaClient({ url: 'http://localhost:9876/?id=123456' });
client.connect();
client.on('execute', () => console.log('Loading files ...'));
client.on('result', e => console.log(`Running tests (${e.completed} / ${e.total})`));
client.on('complete', e => {
	let resultMessage = `Executed ${e.total - e.skipped} / ${e.total}`;
	if (e.failed) {
		resultMessage += ` (${e.failed} FAILED)`;
	}
	resultMessage += ' - DONE';
	console.log(resultMessage);
});

Public API

new KarmaClient(options)

Creates a new KarmaClient instance and sets the passed options. The options object can contain the following settings:

| Name | Type | Required | Description | | --- | --- | --- | --- | | url | Sring | Yes | The base url of the Karma server to connect to. If the URL contains an id query parameter the client will register to the Karma server using this identifer. If the parameter is missing the client generates a random identifier to connect with. | | singleRun | Boolean | No | Disconnect the client from the Karma server after a single run. Used in consuction with the Karma config of the same name. Defaults to false. |

KarmaClient.connect()

Connects to the Karma server and starts the test run.

KarmaClient.disconnect()

Disconnects the client from the Karma server.

Event API

KarmaClient implements the Node event emitter API. Refer to https://nodejs.org/api/events.html for a full API documention.

Events

You can listen to a set of events to respond to certain status changes using the on method. Available events are:

  • execute Emitted when the Karma server sends the execute message. This will cause the client to start loading all required files for the test run from the Karma server.
  • result This event will be emitted when the client reports a test result back to Karma. The event will include information about the current number of completed tests as well as the total number of tests being executed.
    • completed <Number> The number of completed tests
    • total <Number> The number of total tests in this test run
  • complete Emitted when the test run is complete. Includes information about skipped and failed tests and the total number of tests executed.
    • skipped <Number> Number of skipped tests
    • failed <Number> Number of failed tests
    • total <Number> Total tests executed during this run

Contributions

Open source contributions are greatly appreciated! If you have a bugfix, improvement or new feature, please create an issue first and submit a pull request against master.

Getting Help

If you have questions about unit testing your Titanium apps or libraries with Karma, feel free to reach out on Stackoverflow or the #helpme channel on TiSlack. In case you find a bug related to this library, create a new issue or open a new JIRA ticket.

License

Apache License, Version 2.0