You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pact requires a Node runtime to be able to start and stop Mock servers, write logs and other things.
377
+
378
+
However, when used within browser or non-Node based environments - such as with Karma or ng-test
379
+
- this is not possible.
380
+
381
+
To address this challenge, we have released a separate 'web' based module for this purpose - `pact-web`.
382
+
Whilst it still provides a testing DSL, it cannot start and stop mock servers as per the `pact`
383
+
package, so you will need to coordinate this yourself prior to and after executing any tests.
384
+
385
+
To get started, install `pact-web` and [Pact Node](https://github.com/pact-foundation/pact-node):
386
+
387
+
npm install --save-dev pact-web pact-node
388
+
389
+
If you're not using Karma, you can start and stop the mock server using [Pact Node](https://github.com/pact-foundation/pact-node) or something like [Grunt Pact](https://github.com/pact-foundation/grunt-pact).
390
+
391
+
### Using Pact with Karma
392
+
393
+
We have create a [plugin](https://github.com/pact-foundation/karma-pact) for Karma,
394
+
which will automatically start and stop any Mock Server for your Pact tests.
395
+
396
+
Modify your `karma.conf.js` file as per below to get started:
397
+
398
+
```js
399
+
// Load pact framework - this will start/stop mock server automatically
400
+
frameworks: ['pact'],
401
+
402
+
// load pact web
403
+
files: [
404
+
'node_modules/pact-web/pact-web.js',
405
+
...
406
+
]
407
+
```
408
+
409
+
Check out the [Examples](/pact-foundation/pact-js#examples) for how to use the Karma interface.
410
+
372
411
## Troubleshooting
373
412
374
413
If you are having issues, a good place to start is setting `logLevel: 'DEBUG'`
0 commit comments