Skip to content

Commit d45f898

Browse files
committed
feat: drop support for pact web incl. karma examples
1 parent be8ed15 commit d45f898

File tree

16 files changed

+1344
-12292
lines changed

16 files changed

+1344
-12292
lines changed

.codeclimate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ exclude_paths:
1616
- "config/**/*"
1717
- "dist/**.js"
1818
- "examples/**/*"
19-
- "karma/**/*"
2019
- "test/**/*"
2120
- "docs/**/*"

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
config/
44
coverage/
55
docs/
6-
karma/
6+
/
77
logs/
88
pacts/
99
test/

README.md

Lines changed: 5 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ Read [Getting started with Pact] for more information for beginners.
7272
- [Examples](#examples)
7373
- [HTTP APIs](#http-apis)
7474
- [Asynchronous APIs](#asynchronous-apis)
75-
- [Using Pact in non-Node environments](#using-pact-in-non-node-environments)
76-
- [Using Pact with Karma](#using-pact-with-karma)
77-
- [Using Pact with RequireJS](#using-pact-with-requirejs)
75+
- [Using Pact in non-Node environments such as Karma](#using-pact-in-non-node-environments-such-as-karma)
7876
- [Pact JS V3](#pact-js-v3)
7977
- [Using the V3 matching rules](#using-the-v3-matching-rules)
8078
- [Using Pact with XML](#using-pact-with-xml)
@@ -204,7 +202,7 @@ The first step is to create a test for your API Consumer. The example below uses
204202
1. Validate the expected interactions were made between your consumer and the Mock Service
205203
1. Generate the pact(s)
206204

207-
Check out the `examples` folder for examples with Karma Jasmine, Mocha and Jest. The example below is taken from the [integration spec](https://github.com/pact-foundation/pact-js/blob/master/src/pact.integration.spec.ts).
205+
Check out the `examples` folder for examples with Mocha and Jest. The example below is taken from the [integration spec](https://github.com/pact-foundation/pact-js/blob/master/src/pact.integration.spec.ts).
208206

209207
```javascript
210208
const path = require("path")
@@ -935,109 +933,24 @@ The workshop takes you through all of the key concepts using a React consumer an
935933
- [Pact with TypeScript + Mocha](https://github.com/pact-foundation/pact-js/tree/master/examples/typescript)
936934
- [Pact with Mocha](https://github.com/pact-foundation/pact-js/tree/master/examples/mocha)
937935
- [Pact with GraphQL](https://github.com/pact-foundation/pact-js/tree/master/examples/graphql)
938-
- [Pact with Karma + Jasmine](https://github.com/pact-foundation/pact-js/tree/master/examples/karma/jasmine)
939-
- [Pact with Karma + Mocha](https://github.com/pact-foundation/pact-js/tree/master/examples/karma/mocha)
940936
- [Pact with React + Jest](https://github.com/pact-foundation/pact-workshop-js)
941937

942938
### Asynchronous APIs
943939

944940
- [Asynchronous messages](https://github.com/pact-foundation/pact-js/tree/master/examples/messages)
945941
- [Serverless](https://github.com/pact-foundation/pact-js/tree/master/examples/serverless)
946942

947-
## Using Pact in non-Node environments
943+
## Using Pact in non-Node environments such as Karma
948944

949945
Pact requires a Node runtime to be able to start and stop Mock servers, write logs and other things.
950946

951947
However, when used within browser or non-Node based environments - such as with Karma or ng-test - this is not possible.
952948

953-
To address this challenge, we have released a separate 'web' based module for this purpose - `pact-web`.
954-
Whilst it still provides a testing DSL, it cannot start and stop mock servers as per the `pact`
955-
package, so you will need to coordinate this yourself prior to and after executing any tests.
956-
957-
To get started, install `pact-web` and [Pact Node](https://github.com/pact-foundation/pact-node):
958-
959-
NPM
960-
```sh
961-
npm install --save-dev @pact-foundation/pact-web @pact-foundation/pact-node
962-
```
963-
964-
Yarn
965-
966-
```sh
967-
yarn add --dev @pact-foundation/pact-web @pact-foundation/pact-node
968-
```
969-
970-
- Ensure you install the package as `devDependencies` by using [`--save-dev`][npm-devdep]/[`--dev`][yarn-devdep] ;
971-
- Make sure the `ignore-scripts` option is disabled, pact uses npm scripts to download further dependencies.
972-
- 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).
973-
974-
### Using Pact with Karma
975-
976-
We have create a [plugin](https://github.com/pact-foundation/karma-pact) for Karma,
977-
which will automatically start and stop any Mock Server for your Pact tests.
978-
979-
Modify your `karma.conf.js` file as per below to get started:
980-
981-
```js
982-
// Load pact framework - this will start/stop mock server automatically
983-
frameworks: ['pact'],
984-
985-
// Load the pact and default karma plugins
986-
plugins: [
987-
'karma-*',
988-
'@pact-foundation/karma-pact'
989-
],
990-
991-
// load pact web module
992-
files: [
993-
'node_modules/@pact-foundation/pact-web/pact-web.js',
994-
...
995-
],
996-
997-
// Configure the mock service
998-
pact: [{
999-
port: 1234,
1000-
consumer: 'KarmaMochaConsumer',
1001-
provider: 'KarmaMochaProvider',
1002-
logLevel: 'DEBUG',
1003-
log: path.resolve(process.cwd(), 'logs', 'pact.log'),
1004-
dir: path.resolve(process.cwd(), 'pacts')
1005-
}],
1006-
```
1007-
1008-
Check out the [Examples](#examples) for how to use the Karma interface.
1009-
1010-
### Using Pact with RequireJS
1011-
1012-
The module name should be "Pact" - not "pact-js". An example config with a karma test might look
1013-
like the following:
1014-
1015-
In `client-spec.js` change the `define` to:
1016-
1017-
```js
1018-
define(['client', 'Pact'], function (example, Pact) {
1019-
```
1020-
1021-
In `test-main.js`:
1022-
1023-
```js
1024-
require.config({
1025-
baseUrl: "/base",
1026-
paths: {
1027-
Pact: "node_modules/pact-web/pact-web",
1028-
client: "js/client",
1029-
},
1030-
deps: allTestFiles,
1031-
callback: window.__karma__.start,
1032-
})
1033-
```
1034-
1035-
See this [Stack Overflow](https://stackoverflow.com/a/44170373/1008568) question for background, and
1036-
this [gist](https://gist.github.com/mefellows/15c9fcb052c2aa9d8951f91d48d6da54) with a working example.
949+
You will need a Node based test framework such as Jest or Mocha.
1037950

1038951
## Pact JS V3
1039952

1040-
An initial alpha version of Pact-JS with support for V3 specification features and XML matching has
953+
An initial beta version of Pact-JS with support for V3 specification features and XML matching has
1041954
been released. Current support is for Node 10, 12 and 14. Thanks to the folks at [Align Tech](https://www.aligntech.com/) for sponsoring this work.
1042955

1043956
To install it:

config/webpack.web.config.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

examples/karma/jasmine/client-spec.js

Lines changed: 0 additions & 190 deletions
This file was deleted.

0 commit comments

Comments
 (0)