Skip to content

Commit 302357f

Browse files
committed
fix(verification): pass validation error message on #114
1 parent b6866ef commit 302357f

2 files changed

Lines changed: 75 additions & 80 deletions

File tree

src/pact-web.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ export class PactWeb {
9898
return this.mockService.verify()
9999
.then(() => this.mockService.removeInteractions())
100100
.catch((e: any) => {
101-
// Properly format the error
102-
console.error('');
103-
console.error('Pact verification failed!');
104-
console.error(e);
105-
106-
throw new Error('Pact verification failed - expected interactions did not match actual.');
101+
throw new Error(e);
107102
});
108103
}
109104
/**

test/dsl/integration.spec.js

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ describe('Integration', () => {
3232
name: 'Project 1',
3333
due: '2016-02-11T09:46:56.023Z',
3434
tasks: [{
35-
id: 1,
36-
name: 'Do the laundry',
37-
'done': true
38-
},
39-
{
40-
id: 2,
41-
name: 'Do the dishes',
42-
'done': false
43-
},
44-
{
45-
id: 3,
46-
name: 'Do the backyard',
47-
'done': false
48-
},
49-
{
50-
id: 4,
51-
name: 'Do nothing',
52-
'done': false
53-
}
35+
id: 1,
36+
name: 'Do the laundry',
37+
'done': true
38+
},
39+
{
40+
id: 2,
41+
name: 'Do the dishes',
42+
'done': false
43+
},
44+
{
45+
id: 3,
46+
name: 'Do the backyard',
47+
'done': false
48+
},
49+
{
50+
id: 4,
51+
name: 'Do nothing',
52+
'done': false
53+
}
5454
]
5555
}]
5656

@@ -66,23 +66,23 @@ describe('Integration', () => {
6666
// add interactions, as many as needed
6767
before((done) => {
6868
provider.addInteraction({
69-
state: 'i have a list of projects',
70-
uponReceiving: 'a request for projects',
71-
withRequest: {
72-
method: 'get',
73-
path: '/projects',
74-
headers: {
75-
'Accept': 'application/json'
76-
}
77-
},
78-
willRespondWith: {
79-
status: 200,
80-
headers: {
81-
'Content-Type': 'application/json'
69+
state: 'i have a list of projects',
70+
uponReceiving: 'a request for projects',
71+
withRequest: {
72+
method: 'get',
73+
path: '/projects',
74+
headers: {
75+
'Accept': 'application/json'
76+
}
8277
},
83-
body: EXPECTED_BODY
84-
}
85-
})
78+
willRespondWith: {
79+
status: 200,
80+
headers: {
81+
'Content-Type': 'application/json'
82+
},
83+
body: EXPECTED_BODY
84+
}
85+
})
8686
.then(() => done())
8787
})
8888

@@ -108,26 +108,26 @@ describe('Integration', () => {
108108
// add interactions, as many as needed
109109
before((done) => {
110110
provider.addInteraction({
111-
state: 'i have a list of projects',
112-
uponReceiving: 'a request for projects with a filter',
113-
withRequest: {
114-
method: 'get',
115-
path: '/projects',
116-
query: {
117-
from: 'today'
111+
state: 'i have a list of projects',
112+
uponReceiving: 'a request for projects with a filter',
113+
withRequest: {
114+
method: 'get',
115+
path: '/projects',
116+
query: {
117+
from: 'today'
118+
},
119+
headers: {
120+
'Accept': 'application/json'
121+
}
118122
},
119-
headers: {
120-
'Accept': 'application/json'
123+
willRespondWith: {
124+
status: 200,
125+
headers: {
126+
'Content-Type': 'application/json'
127+
},
128+
body: EXPECTED_BODY
121129
}
122-
},
123-
willRespondWith: {
124-
status: 200,
125-
headers: {
126-
'Content-Type': 'application/json'
127-
},
128-
body: EXPECTED_BODY
129-
}
130-
})
130+
})
131131
.then(() => done())
132132
})
133133

@@ -179,8 +179,8 @@ describe('Integration', () => {
179179
name: Matchers.somethingLike('Do the laundry'),
180180
'done': Matchers.somethingLike(true)
181181
}, {
182-
min: 4
183-
})
182+
min: 4
183+
})
184184
}]
185185
}
186186
}).then(() => done())
@@ -251,12 +251,12 @@ describe('Integration', () => {
251251
it('allows two requests', (done) => {
252252
const verificationPromise =
253253
request.get(`${PROVIDER_URL}/projects`)
254-
.set({
255-
'Accept': 'application/json'
256-
})
257-
.then((res) => {
258-
return res.text
259-
})
254+
.set({
255+
'Accept': 'application/json'
256+
})
257+
.then((res) => {
258+
return res.text
259+
})
260260
expect(verificationPromise).to.eventually.eql(JSON.stringify(EXPECTED_BODY)).notify(done)
261261

262262
const verificationPromise404 =
@@ -298,19 +298,19 @@ describe('Integration', () => {
298298

299299
const verificationPromise =
300300
request.get(`${PROVIDER_URL}/projects`)
301-
.set({
302-
'Accept': 'application/json'
303-
})
304-
.then((response) => {
305-
promiseResults.push(response)
306-
return request.delete(`${PROVIDER_URL}/projects/2`)
307-
})
308-
.then(() => { }, (err) => {
309-
promiseResults.push(err.response)
310-
})
311-
.then(() => provider.verify(promiseResults))
312-
313-
expect(verificationPromise).to.be.rejectedWith('Error: Pact verification failed - expected interactions did not match actual.').notify(done)
301+
.set({
302+
'Accept': 'application/json'
303+
})
304+
.then((response) => {
305+
promiseResults.push(response)
306+
return request.delete(`${PROVIDER_URL}/projects/2`)
307+
})
308+
.then(() => {}, (err) => {
309+
promiseResults.push(err.response)
310+
})
311+
.then(() => provider.verify(promiseResults))
312+
313+
expect(verificationPromise).to.be.rejected.notify(done)
314314
})
315315
})
316316
})

0 commit comments

Comments
 (0)