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

@pact-foundation/karma-pact

v3.1.0

Published

Launches a Pact Mock Server for Karma

Downloads

5,120

Readme

Karma Pact

Build Status Known Vulnerabilities

Implementation of a Karma Plugin to launch a Pact Mock Server before executing your Pact tests on the browser.

From the Pact website:

The Pact family of frameworks provide support for Consumer Driven Contracts testing.

A Contract is a collection of agreements between a client (Consumer) and an API (Provider) that describes the interactions that can take place between them.

Consumer Driven Contracts is a pattern that drives the development of the Provider from its Consumers point of view.

Pact is a testing tool that guarantees those Contracts are satisfied.

Read Getting started with Pact for more information on how to get going.

Installation

First install the package from NPM:

npm install --save-dev @pact-foundation/karma-pact @pact-foundation/pact-node

Pact-node must be installed as a peer dependency of karma-pact, as to allow developers to have more freedom to use any version of pact-node. Then, on your Karma Configuration file, add the below:

module.exports = function (config) {
  config.set({
    // in here we are simply telling to use Jasmine with Pact
    frameworks: ['jasmine', 'pact'],
	// the Pact options will go here, you can start
	// as many providers as you need
    pact: [{
    	port: 1234,
    	consumer: "some-consumer",
    	provider: "some-provider",
		dir: "pact/files/go/here",
		log: "log/files/go/here"
	}],
	// ensure Pact and default karma plugins are loaded
    plugins: [
      'karma-*',
      '@pact-foundation/karma-pact',
    ],
  });
};

The pact option can be configured using a single object to spin up a single service, or can be passed an array of objects which will spin up multiple pact services, representing each of your various provider services.

Please be sure not to have the same port number between options as they will conflict with each other. All options are passed directly into Pact Node, which has the full list of available options.

It is recommended, however, to specify the port number, consumer and provider at a minimum to prevent common issues.

Examples

Check the karma folder under Pact JS for examples with Mocha and Jasmine.

Running multiple Pact Mock Servers

In some situations it may be useful to run multiple Pact Mock Servers. For instance, when running tests with karma, if a consumer defines contracts for several providers, the generated Pact contracts may be mixed up. A solution to solve this is to run one Pact Mock Server per provider.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

The vision is to have a compatible Pact implementation in all the commonly used languages, your help would be greatly appreciated!

Questions?

Please search for potential answers or post question on our official Pact StackOverflow, or join us on Slack