Heera Singh
08/18/2022, 11:33 AMProvider verification
(fetching contracts from pact broker)
I gets error message:
ERROR ThreadId(11) pact_verifier: Failed to load pact - Could not load pacts from the pact broker 'https://rain.pactflow.io' - ContentError("Request to pact broker URL 'https://rain.pactflow.io/pacts/provider/ATP_Provider/for-verification' failed - HTTP status client error (400 Bad Request) for url (https://rain.pactflow.io/pacts/provider/ATP_Provider/for-verification)")
To publish the contract I use command
"publish:pact": "pact-broker publish ./pacts --consumer-app-version 1.0.1 --auto-detect-version-properties --broker-base-url=https://**.<http://pactflow.io|pactflow.io> --broker-token=**"
I provide these options to Verifier
const opts = {
provider: "MY_Provider",
logLevel: process.env.LOG_LEVEL,
providerBaseUrl: process.env.BASE_URL,
stateHandlers: {
"when no auth passed": () => {
return Promise.resolve("no token needed");
},
},
pactBrokerUrl: process.env.PACT_BROKER_URL,
pactBrokerToken: process.env.PACT_BROKER_TOKEN,
publishVerificationResult: true,
consumerVersionSelectors: [
{
consumer: "10.0.1",
},
],
providerVersion: "1.0.0",
};
Any clue what I am doing wrong here.Abdurahman Hijazi
08/19/2022, 11:36 AMBrendan Donegan
08/22/2022, 8:10 AMasync
state handler functions be supported in theory? a team has recently upgraded their node version and broken the verification. when i make the state handler function that was async not async (hardcode the needed response) then it works okAbdurahman Hijazi
08/22/2022, 10:21 AMHarold Robson
08/23/2022, 9:01 AMRavi Shankar
08/24/2022, 6:05 AMAbdurahman Hijazi
08/24/2022, 1:56 PMmockProvider.addInteraction({
state: "",
uponReceiving: `An invalid POST request to ${Config.config.SSO_TOKEN_PATH}. Returns 400 status and "invalid_grant_type" message`,
withRequest: {
method: "POST",
path: "/v1/api/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
body: createFormBody(request),
},
willRespondWith: {
status: 400,
body: {
error: "unsupported_grant_type",
error_description:
"Invalid grant type INCORRECT_GRANT_TYPE, expected authorization_code",
error_uri: null,
},
},
});
But for some reason, when the pact is generated, a header is added in the interaction in the API response
{
"description": "An invalid POST request to /v1/api/token. Returns 400 status and \"invalid_grant_type\" message",
"request": {
"body": "grant_type=INCORRECT_GRANT_TYPE&client_id=34343433434&redirect_uri=REDIRECT_URL&code=AUTH_CODE&code_verifier=VERIFIER",
"headers": {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
"method": "POST",
"path": "/v1/api/token"
},
"response": {
"body": {
"error": "unsupported_grant_type",
"error_description": "Invalid grant type INCORRECT_GRANT_TYPE, expected authorization_code",
"error_uri": null
},
"headers": {
"Content-Type": "application/json"
},
"status": 400
}
}
Any ideas on how to stop this from happeningÉdouard Lopez
08/26/2022, 3:16 PMnpx @pact-foundation/absolute-version
, e.g.:
"pact:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx @pact-foundation/absolute-version)\" --auto-detect-version-properties --broker-base-url=<http://localhost:8000> --broker-username pact_workshop --broker-password pact_workshop"
But the NPM package is deprecated in favour of absolute-version. Should the docs be updated?Édouard Lopez
08/26/2022, 3:22 PMDmitry Munda
08/30/2022, 8:14 AM9.17.3
to 10.1.2
and having
TypeError: includeWipPactsSince
looks like it cant be undefined
anymore
line triggering error
includeWipPactsSince: isCI ? new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split("T")[0] : undefined,
Lennart Querter
08/30/2022, 9:39 AMMac M1 pro
"@pact-foundation/pact": "^10.1.2"
"jest": "^29.0.1",
"ts-jest": "^28.0.8",
Error:
Error in native callback
at Object.mockServerMismatches (node_modules/@pact-foundation/pact-core/src/consumer/index.ts:94:13)
at PactV3.<anonymous> (node_modules/@pact-foundation/src/v3/pact.ts:207:39)
at step (node_modules/@pact-foundation/pact/src/v3/pact.js:33:23)
at Object.throw (node_modules/@pact-foundation/pact/src/v3/pact.js:14:53)
at rejected (node_modules/@pact-foundation/pact/src/v3/pact.js:6:65)
Github repo for reproduction:
https://github.com/lennartquerter/pact-v3-test
Commands:
yarn install && yarn test:pactv3
Semih Ural
09/01/2022, 10:43 AMDave Gordon
09/01/2022, 9:31 PMnpm install
?
What caused me problems was the react version on step1 was older than the master branch and resulted in Attempted import error: 'Routes' is not exported from 'react-router-dom'.
If I had installed from master, it would have been fine.
I added this pull request to update those react versions in step1
I was thinking it might make the tutorial easier if the same package.json dependancies were present on each of the step branches?
So no matter what step a user opts to run npm install
on they will be able to run prior or subsequent steps without having to run the install again? Any thoughts on that?Alan
09/02/2022, 4:36 PMЗлата Кутузова
09/06/2022, 10:38 AMMaxim Filimonov
09/06/2022, 10:39 AMpact_verify
setup broke.
In prev. version pact-js
used to publish based on env variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS
.
In the latest version(pact-core: 13.7.8, pact: 10.1.2) option needs to be specified manually in pact config publishVerificationResult: process.env.PACT_BROKER_PUBLISH_VERIFICATION_RESULTS === 'true'
However, now it leads to errors as even after specifying PACT_BROKER_URL
pact cannot publish results. See logs in threadSneha Singh
09/07/2022, 1:30 PM'use strict'
process.env.REACT_APP_ENGINE_SERVICE_URL = '<http://localhost:8992>'
import { expect } from 'chai'
import path from 'path'
import { Pact } from '@pact-foundation/pact'
import { fetchACEFields } from '../api/index'
describe('fetch ACE fields', () => {
const port = 8992
const objectType = 'dummy'
const provider = new Pact({
port: port,
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'),
dir: path.resolve(process.cwd(), 'pacts'),
spec: 2,
consumer: 'webapp',
provider: 'engine-service',
pactfileWriteMode: 'merge',
})
const expectedBody = { status: true, data: [{ fullName: 'dummy' }] }
before(() => provider.setup())
after(() => provider.finalize())
afterEach(() => provider.verify())
describe('request to fetch fields', () => {
before(done => {
const interaction = {
state: 'fetch ace fields',
uponReceiving: 'a request to get all ace fields',
withRequest: {
method: 'GET' as const,
path: `/ace-fields?object_type=${objectType}`,
headers: {
Accept: 'application/json',
},
},
willRespondWith: {
status: 200,
headers: {
'Content-Type': 'application/json',
},
body: expectedBody,
},
}
provider.addInteraction(interaction).then(() => {
done()
})
})
it('verify it returns the correct response', async () => {
const res = await fetchACEFields(objectType)
expect(res).equal(expectedBody)
})
})
})
Error:
ReferenceError: navigator is not defined
at Object.<anonymous> (/Users/snehasingh/Documents/webapp/node_modules/flags/node_modules/supports-color/browser.js:3:58)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Object.require.extensions.<computed> [as .js] (/Users/snehasingh/Documents/webapp/node_modules/ts-node/src/index.ts:1445:43)
Xiaofeng Xie
09/08/2022, 4:22 AMpino
is not a function error?
TypeError: pino is not a function
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/logger/pino.ts
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/logger/index.ts
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/service.ts
I got this error when I tried to do
const provider = new PactV3({consumer:"foo",provider:"bar"});
Sneha Singh
09/08/2022, 1:41 PM'use strict'
import { setupServer } from 'msw/node'
import { rest } from 'msw'
import { fetchFields } from '../api/index'
import provider from './provider'
import interactions from './interactions/interactions'
describe('fetch fields', () => {
const expectedBody = { status: true, data: [{ fullName: 'dummy' }] }
const server = setupServer(
rest.get(
`<http://localhost:8992/fields?object_type=dummy>`,
(req, res, ctx) =>
res(
ctx.status(200),
ctx.json(expectedBody)
)
)
)
beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
describe('request to fetch ACE fields', () => {
beforeAll(async () => {
await provider.setup();
await provider.addInteraction(interactions.fetchAceFields);
});
test('verify it returns the correct response', async () => {
const res = await fetchFields("dummy")
expect(res.data).toEqual(expectedBody)
})
})
})
Maxim Filimonov
09/09/2022, 5:35 AMexecuteTest
? We are getting weird pact errors:Harry
09/12/2022, 6:24 AMAbdel Aziz Akkoub
09/14/2022, 2:10 AM```
Here is the debug output when run with Node 18.9.0:
```
The major difference in the logs is the lack of reference to the tokio-runtime-worker. I have spent the entire day attempting to debug this issue with no luck being able to generate the tests. I also attempted to run Node 18.9.0 with different versions of the @User/pact (8.2.6 and 9.17.2) with no luck! Any advice is hight appreciated!Abdel Aziz Akkoub
09/14/2022, 2:45 AM/* eslint-env jest */
import { Pact, GraphQLInteraction, Matchers } from '@pact-foundation/pact';
import * as path from 'path'
import fetch from 'node-fetch'
import { createApolloClient } from '../../src/plugins/apollo-vue-setup'
import BusinessNeedService from '../../src/services/businessNeedService'
import { print } from 'graphql'
import { gql } from '@apollo/client/core'
const pactTestTimeout = 30000
describe('GraphQL example', () => {
const port = 8992
const baseUri = `<https://localhost>:${port}`
const provider = new Pact({
port: port,
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'),
logLevel: 'debug',
dir: path.resolve(process.cwd(), 'pacts'),
consumer: 'UI',
provider: 'BusinessNeedApollo',
});
const accessToken = 'authToken'
const environmentLevel = 'qa'
const siteName = 'qa026'
const clientSiteId = 'siteId'
const language = 'en-US'
const getAccessTokenAsync = () => accessToken
const getBeelineHeaderValues = () => ({
environmentLevel,
siteName,
clientSiteId,
language
})
const defaultHeaders = {
'x-beeline-environment-level': environmentLevel,
'x-beeline-site-name': siteName,
'x-beeline-client-site-id': clientSiteId,
'Content-Type': 'application/json',
'accept-language': language,
Authorization: `bearer ${accessToken}`
}
const defaultRequest = {
method: 'POST',
path: '/graphql',
headers: defaultHeaders
}
const defaultApolloClient = createApolloClient({
baseUri,
fetch,
getAccessTokenAsync,
getBeelineHeaderValues
})
beforeAll(() => provider.setup());
afterAll(() => provider.finalize());
describe('query hello on /graphql', () => {
beforeAll(() => {
const graphqlQuery = new GraphQLInteraction()
.uponReceiving('A request to get requests')
.given('user has business need requests and is authenticated')
.withQuery(print(gql`query{
quickRequests(skip: $skip, top: $top, search: $search, orderBy: $orderBy) {
items {
clientName
cost {
billRate
estimatedCost
__typename
}
createDate
industryId
jobDescription
jobTitle
requestId
requestType
workLocation
__typename
}
totalCount
__typename
}
}`))
.withVariables()
.withOperation()
.withRequest(defaultRequest)
.willRespondWith({
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: Matchers.like({
data: {
quickRequests: {
items: [
{
clientName: 'QA027',
cost: {
billRate: '$488.75',
estimatedCost: '$320,317.50',
__typename: 'Cost'
},
createDate: '2020-04-21T19:32:31.000Z',
industryId: '12345',
jobDescription: 'This is a description',
jobTitle: 'Accountant (General)',
requestType: 'Staff Aug - Approved Budget With Position ID',
requestId: 'e234e7aa-54b7-4735-a170-a08ce280c411',
workLocation: 'Plantation, FL',
__typename: 'QuickRequest'
}
],
totalCount: 100,
__typename: 'QuickRequestPage'
}
}
})
}
)
return provider.addInteraction(graphqlQuery);
});
it('returns the correct response', async () => {
const businessNeedService = new BusinessNeedService(defaultApolloClient)
const requests = await businessNeedService.getQuickRequests();
expect(requests.items).toHaveLength(1)
});
//verify with Pact, and reset expectations
afterEach(() => provider.verify());
});
});
I can't post the two output messages in the entire threads, so I saved each output to a text file and attached them to the thread. The major difference in the logs is the lack of reference to the tokio-runtime-worker I am seeing when the tests fails. I have spent the entire day attempting to debug this issue with no luck being able to generate the tests. I also attempted to run Node 18.9.0 with different versions of the @ pact-foundation/pact (8.2.6 and 9.17.2) with no luck! Any advice is highly appreciated!Maxim Filimonov
09/14/2022, 10:55 AMuseQuery
Apollo hook? Cannot seem to find any on github or in the docs.Adam Witko
09/14/2022, 12:59 PMAlessandro Catania
09/16/2022, 10:35 AMMaksym Liannoi
09/19/2022, 5:06 AMpact-foundation/pact
to version "^10.1.3"
, - all our tests (that are written on jest-pact library) failed with Axios Network Error and following stack trace. So, even if I want to rewrite one of them on pact-js library, errors never go away. So, tell me please, what is going wrong?
Network Error
at createError (node_modules/axios/lib/core/createError.js:16:15)
at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:117:14)
at XMLHttpRequest.invokeTheCallbackFunction (node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:18:28)
at XMLHttpRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:35:32)
at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
at XMLHttpRequestImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
at fireAnEvent (node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36)
at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:131:3)
at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:60:3)
at validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:75:5)
at validCORSPreflightHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:89:8)
at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:374:12)
at Request._processResponse (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:228:12)
at ClientRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:101:12)
Zebi
09/20/2022, 11:07 AMeachKeyLike
. Is it possible to use eachKeyLike
for nested (up-to 3 levels) dynamic keys? It seems that it only works on one level but in my use case, we can have nested dynamic keys and I just want to ensure the shape of the request/response payload. Any help would be appreciated. An example payload is as follows:
{
"john-doe1": {
"brown-fox": {
"jumps": "over",
"the": "lazy dog"
}
},
"john-doe2": {
"brown-fox2": {
"jumps": "over",
"the": "lazy dog"
}
}
}
And the matcher which I am trying to use is as follows (roughly). It skips checking the first level of the keys (as expected) but then it compares the other keys literally:
Matchers.eachKeyLike("some string", Matchers.eachKeyLike("some-string", Matchers.eachKeyLike("some-string", Matchers.string())))
Matt (pactflow.io / pact-js / pact-go)
Édouard Lopez
09/21/2022, 2:12 PM@pact-foundation/pact
trigger this message:
[ERROR] 15:54:14 TypeError: destination.on is not a function
We are using our yarn dev
to start the app instead of what you do in the workshop that do as follow:
"dev": "NODE_ENV='development' yarn generate-routes && yarn just-build && tsnd --inspect -r dotenv/config --respawn --files src/index.js",