This example project shows how to setup an Angular application to use Pact in order to create Pact files from a consumer test and validate the a consumer against the Pact.
Creating a Consumer-Driven Contract with Angular and Pact
user.service.ts
: Angular service that calls a REST backend to manage usersuser.service.pact.spec.ts
: Jasmine-based consumer test ofuser.service.ts
karma.conf.js
: configuration of the Karma test runner including configuration to setup Pact
Run npm install
to load the needed javascript libraries and then npm run test
to
run the tests. After the tests have successfully run the created pact file will be
created in the folder pacts
.
Then, you can call npm run publish-pacts
to publish the pact files to a Pact Broker.
You must set the following npm configs for the publish-pacts
script to work:
npm config set angular-pact:brokerUrl <URL>
npm config set angular-pact:brokerUsername <USER>
npm config set angular-pact:brokerPassword <PASS>