Skip to content

Commit c11403d

Browse files
committed
added react pact example
1 parent e8786b1 commit c11403d

21 files changed

Lines changed: 16211 additions & 1 deletion

.idea/modules/spring-boot-testing.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

pact/pact-react-consumer/README.md

Whitespace-only changes.

pact/pact-react-consumer/package-lock.json

Lines changed: 15633 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "pact-react-consumer",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"react": "^16.5.2",
7+
"react-dom": "^16.5.2",
8+
"react-scripts": "2.0.5",
9+
"axios": "0.18.0"
10+
},
11+
"devDependencies": {
12+
"@pact-foundation/pact": "7.0.1",
13+
"@pact-foundation/pact-node": "6.20.0",
14+
"cross-env": "^5.2.0"
15+
},
16+
"scripts": {
17+
"start": "react-scripts start",
18+
"build": "react-scripts build",
19+
"test": "react-scripts test",
20+
"test:pact": "cross-env CI=true react-scripts test --runInBand --setupFiles ./pact/setup.js --setupTestFrameworkScriptFile ./pact/jest-wrapper.js --testMatch \"**/*.test.pact.js\"",
21+
"publish:pact": "node pact/publish.js",
22+
"eject": "react-scripts eject"
23+
},
24+
"eslintConfig": {
25+
"extends": "react-app"
26+
},
27+
"browserslist": [
28+
">0.2%",
29+
"not dead",
30+
"not ie <= 11",
31+
"not op_mini all"
32+
]
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
beforeAll((done) => {
2+
global.provider.setup().then(() => done());
3+
});
4+
5+
afterAll((done) => {
6+
global.provider.finalize().then(() => done());
7+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
let publisher = require('@pact-foundation/pact-node');
2+
let path = require('path');
3+
4+
let opts = {
5+
providerBaseUrl: 'http://localhost:8080',
6+
pactFilesOrDirs: [path.resolve(process.cwd(), 'pacts')],
7+
pactBroker: 'https://adesso.pact.dius.com.au/',
8+
pactBrokerUsername: process.env.PACT_USERNAME,
9+
pactBrokerPassword: process.env.PACT_PASSWORD,
10+
consumerVersion: '2.0.0'
11+
};
12+
13+
publisher.publishPacts(opts).then(() => console.log("Pacts successfully published"));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require('path');
2+
const Pact = require('@pact-foundation/pact').Pact;
3+
4+
global.port = 8080;
5+
global.provider = new Pact({
6+
cors: true,
7+
port: global.port,
8+
log: path.resolve(process.cwd(), 'logs', 'pact.log'),
9+
loglevel: 'debug',
10+
dir: path.resolve(process.cwd(), 'pacts'),
11+
spec: 2,
12+
pactfileWriteMode: 'update',
13+
consumer: 'react-consumer',
14+
provider: 'node-provider',
15+
host: '127.0.0.1'
16+
});
3.78 KB
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<meta name="theme-color" content="#000000">
8+
<!--
9+
manifest.json provides metadata used when your web app is added to the
10+
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
11+
-->
12+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
13+
<!--
14+
Notice the use of %PUBLIC_URL% in the tags above.
15+
It will be replaced with the URL of the `public` folder during the build.
16+
Only files inside the `public` folder can be referenced from the HTML.
17+
18+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
19+
work correctly both with client-side routing and a non-root public URL.
20+
Learn how to configure a non-root public URL by running `npm run build`.
21+
-->
22+
<title>React App</title>
23+
</head>
24+
<body>
25+
<noscript>
26+
You need to enable JavaScript to run this app.
27+
</noscript>
28+
<div id="root"></div>
29+
<!--
30+
This HTML file is a template.
31+
If you open it directly in the browser, you will see an empty page.
32+
33+
You can add webfonts, meta tags, or analytics to this file.
34+
The build step will place the bundled scripts into the <body> tag.
35+
36+
To begin the development, run `npm start` or `yarn start`.
37+
To create a production bundle, use `npm run build` or `yarn build`.
38+
-->
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)