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

grunt-pact-js

v0.3.0-SNAPSHOT

Published

Generating Pact Consumer Tests with Grunt and Karma

Downloads

3

Readme

grunt-pact-js v0.3.0-SNAPSHOT

Generating Pact Consumer Tests with Grunt and Karma

Note that this is not an official Grunt plugin release! If you want to use this in a project, please be sure to follow the instructions for installing development versions, as outlined in the Installing Grunt guide.

Getting Started

This plugin requires Grunt ``

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-pact-js --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-pact-js');

The "contracttest" tasks

Run this task with the grunt contracttest command.

This plugin relies on the Ruby pact-mock_service. Please read the chapter Install the Mock Server

Install pact consumer library

For your tests you need pact-consumer-js-dsl. Install the library with bower or nodejs and make it accessible over your karmer config file.

bower install pact-consumer-js-dsl --save-dev
module.exports = function (config) {
    config.set({
        ...

        // list of files / patterns to load in the browser
        files: [
          // if you are using this example to setup your own project load pact from the node_modules directory
          // i.e. node_modules/pact-consumer-js-dsl/dist/pact-consumer-js-dsl.js
          'app/bower_components/pact-consumer-js-dsl/dist/pact-consumer-js-dsl.js',

        ],
        ...
    }
}

Install Ruby, Gem, Bundler and Pact-MockServer

OS X or Linux

This task requires you to have Ruby, Bundler and RubyGems installed. If you're on OS X or Linux you probably already have Ruby installed; test with ruby -v in your terminal. When you've confirmed you have Ruby installed, run gem install bundler.

Windows

If on Windows, please refer to the Installing pact-mock-service on Windows

Windows users must run the install command after following Wiki instructions

(This Plugin is not tested with Windows)

Install Mock Server

Depending on your use case you can use different commands.

Using the grunt plugin in a project

Run the grunt task grunt installMockService.

Developing the plugin

Execute bundle install inside the grunt pact js project folder to install pact-mock_service.

Options

If you will change some option you can do this for example with:

grunt.initConfig({
        contractTest: {
            options: {
                mockServicePort: 8181,
            }
        }
    });

If you want change all configuration you can do this with:

    grunt.initConfig({
        contractTest: {
            options: {
                mockServicePort: 8181,
                karmaConfigFile: 'test/karma.conf.js',
                pactDir: 'tmp'
            }
        },
    });

If you want add a custom Gem file for the mock service you can do this with:

    grunt.initConfig({
        installMockService: {
            options: {
                gemfile: 'your-custom-file-if-you-need'
            }
        },
    });

The current Gem file contains the follow content:

    source 'https://rubygems.org'
    gem 'pact-mock_service', '~> 0.4.1'

It is located in node_modules/grunt-pact-js/Gemfile.

Local set up

To work on this plugin locally, use the npm link feature.

Recreate README.MD

To recreate the README.MD just run grunt build-contrib.

Troubleshooting

  • Karma or any other task doesn't work!
  >> rm -rf node_modules/grunt-pact-js/node_modules/*
  >> npm install
  • Karma still doesn't work and there were errors while npm install

    Make sure python27 is installed and selected:

  >> sudo port select --set python python27
  >> npm install

References

See also:

  • https://github.com/DiUS/pact-consumer-js-dsl
  • https://github.com/bethesque/pact-mock_service/wiki/Integrating-pact-mock-service-with-Grunt-and-Protractor
  • https://github.com/bethesque/pact-mock_service/wiki/Installing-the-pact-mock_service-gem-on-Windows

Release History

  • 2015-03-27   v0.3.0-SNAPSHOT   fixed repo urls in package.json
  • 2015-03-20   v0.2.3   Remove grunt as devDependencies
  • 2015-03-20   v0.2.2   Fixed private flag and grunt-force-task dep
  • 2015-03-20   v0.2.1   Fixed typos in documentation
  • 2015-03-20   v0.2.0   Added config options
  • 2015-03-20   v0.1.0   initial setup

Task submitted by devbliss GmbH

This file was generated on Fri Mar 27 2015 17:48:57.