Pip Brandy
02/07/2022, 3:37 PMnpm install
, and was able to complete step 1. I'm trying step2, I did "git checkout step2" and step 2 seems to have loaded fine. However, when running "npm test --prefix consumer", I get this error: > CI=true react-scripts test
'CI' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Test failed. See above for more details.
Mike Bernard
02/07/2022, 9:57 PMrequestFilter
to intercept each request and add the auth to the headers, but the request object passed in doesn't contain a body.
I've attempted to use SAM CLI to host the API gateway (to bypass auth) but it seems the way we've structured our stacks, the automated sam local start-api
command can't find the lambda functions that we tie to each api. Only other way to use SAM afaik is to hardcode each endpoint into the template.yaml file, and include each request/response model, which isn't viable for our teams to do. TIA!danilchican
02/10/2022, 9:21 AMFrancislainy Campos
02/10/2022, 8:37 PM{
"consumer": {
"name": "Ed UI"
},
"provider": {
"name": "Viaduct"
},
"interactions": [
{
"description": "A POST request to encode a JSON body of claims from the user",
"providerState": "viaductService encodes a JSON body of claims and returns a JWT string in response",
"request": {
"method": "POST",
"path": "/edcore/viaduct-service/jwt",
"body": {
"resourceId": "l_fc3ae9ed-62ac-4b94-8094-8dd29bc208a7_c57760a9-447b-42aa-81df-830134425157",
"teacherAssessmentId": "93a91981-c6f7-435f-ab1e-80588ecff2ee",
"expiryUnixEpochSeconds": 26757854170066,
"sub": "UniqueUserId"
}
},
"response": {
"status": 200,
"body": "eyJhbGciOiJIUzI1NiJ9.eyJU2VydmljZ.blabla",
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
},
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}
However, our provider tests (Java) fail with Expected body 'eyJhbGciOiJIUzI1NiJ9.eyJU2VydmljZ.blabla' to match 'eyJhbGciOiJIUzI1NiJ9.eyJzd.bla' using equality but did not match
. Not sure where the issue could be coming from. Initially I thought it might be related to the headers blocking the matchers as per https://stackoverflow.com/a/61924547/6654475, but even manually deleting the headers from the contract still give us the same issue, so maybe version related perhaps? <pact.version>4.3.2</pact.version>
Thank you. CC @uglyogbbarke
02/11/2022, 12:27 AM@State("with-data") // Method will be run before testing interactions that require "with-data" state
public void toStateWithData(Map data) {
// Prepare service before interaction that require "with-data" state. The provider state data will be passed
// in the data parameter
// ...
System.out.println("Now service in state using data " + data);
}
https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#example-of-http-testDharmesh
02/15/2022, 2:25 PM"description":term(
generate: null,
matcher: /([a-z])|null/),
I have written this it throwing error. can you please help me to resolve it.Mike Geeves
02/21/2022, 9:36 AMCarere
02/21/2022, 3:47 PMCarere
02/21/2022, 8:00 PMnew Verifier(...).verify()
? Is there a proper way to implement a deno version of pact ??Dharmesh
02/24/2022, 10:31 AMAyush
02/24/2022, 11:01 AMQuinn
03/01/2022, 10:18 PMExpected body with content type application/json but was image/jpeg
. Can anyone please help?Matt (pactflow.io / pact-js / pact-go)
Timothy Gates
03/02/2022, 11:56 PM10.0.0-beta.56
to get the timeout fix https://github.com/pact-foundation/pact-js/issues/761
We are running into an issue were the state handlers teardown is no longer being called. I don't see any change in the signature of the state handlers between 10.0.0-beta.54
and the version we are using now. Anyone have any ideas why the teardown isn't be executed? I'll include an example of the code in the thread.Harihara Raj LK
03/03/2022, 9:51 AM"matchingRules": {
"$.body": {
"match": "equality"
}
}
davT
03/03/2022, 1:33 PMDjalmar Gutierrez
03/03/2022, 8:36 PMUnhandled promise rejection: Error: Pact startup failed; tried calling service 10 times with no result.
Nothing else is changed.Alan Boshier
03/04/2022, 5:49 PMGraphQLInteraction
with PactV3? I'm struggling with how to use it in the following approach as I'm not sure PactV3 has an addInteraction()
method:
const provider = new PactV3(...);
describe('query', () => {
beforeEach(() => {
const graphqlQuery = new GraphQLInteraction()
.uponReceiving('a query')
.withQuery('...')
.withVariables({})
.withRequest({
path: '/graphql',
method: 'POST',
})
.willRespondWith({
status: 200,
headers: { ... },
body: { ... }
});
return provider.addInteraction(graphqlQuery); <-- IS THIS VALID?
)};
)};
Artur Neumann
03/07/2022, 7:07 AMQuinn
03/09/2022, 9:41 PMCaíque Coelho
03/10/2022, 7:14 PMGraphQL operations must contain a non-empty query or a persistedQuery
anyone knows how to solve this? I’m sharing my contract bellow and the code I’m using to generate the contractMatt (pactflow.io / pact-js / pact-go)
Alan Boshier
03/12/2022, 3:24 PMarrayContaining
- there are other properties using that matcher which are working fine. Is this a known issue, or is there something in the logs I should be looking for to give me a clue?Matt (pactflow.io / pact-js / pact-go)
arrayContaining
matcher in the v3 beta releaseMircea Ungureanu
03/21/2022, 1:29 PM: Timeout - Async callback was not invoked within the 15000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 15000 ms timeout specified by jest.setTimeout.Error:
I tried increasing the jest timeout but no luck, it’s failing on the return await p.verify();
as it’s an open handle and keeping jest from exiting. Has anyone encountered this before? I’ve sent my access token and url env vars.Bernard Baker
03/22/2022, 1:40 PMtest(`makes a request`, async () => {
jest.setTimeout(30000);
// Arrange
const expectedResult = `Hello World`;
await mockProvider.addInteraction({
state: `foo exists`,
uponReceiving: `a request to get foo`,
withRequest: {
method: `GET`,
path: `/foo`
},
willRespondWith: {
status: 200,
headers: {
"Content-Type": regex({
generate: `text/plain`,
matcher: `text/plain;?.*`
})
},
body: like(expectedResult)
}
});
const request = await <http://axios.post|axios.post>(
`${mockProvider.mockService.baseUrl}/foo`
);
console.log(request);
});
My Pact logs are:
I, [2022-03-22T13:37:53.003897 #348] INFO -- : Registered expected interaction GET /foo
W, [2022-03-22T13:38:22.980712 #348] WARN -- : Verifying - actual interactions do not match expected interactions.
Missing requests:
GET /foo
W, [2022-03-22T13:38:22.980965 #348] WARN -- : Missing requests:
GET /foo
I, [2022-03-22T13:38:23.015926 #348] INFO -- : Cleared interactions
Any ideas?? Do I need to expose a port on my container???Agustin Gomes
03/22/2022, 5:23 PMdocker-compose run --rm node-cli curl -X GET pact-mock-provider:1234
Creating rover_node-cli_run ... done
{"message":"No interaction found for GET /","interaction_diffs":[]}
But if I run the tests, I get the following:
docker-compose run --rm node-cli npm run test:mocha:consumer
Creating rover_node-cli_run ... done
> test:mocha:consumer
> mocha src/consumer.spec.ts
[2022-03-22 17:21:28.234 +0000] INFO (18 on node-cli): pact-node@10.17.2: Creating Pact Server with options:
{"timeout":30000,"consumer":"testingConsumer","cors":false,"dir":"/opt/project/roverctl/pacts","host":"pact-mock-provider","log":"/opt/project/roverctl/stderr","logLevel":"DEBUG","pactfileWriteMode":"overwrite","provider":"testingProvider","spec":2,"ssl":false,"port":1234,"pactFileWriteMode":"overwrite"}
(node:18) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
GraphQL example
1) "before all" hook in "GraphQL example"
[2022-03-22 17:21:28.248 +0000] ERROR (18 on node-cli): pact@9.17.3: The pact mock service doesn't appear to be running
- Please check the logs above to ensure that there are no pact service startup failures
- Please check that pact lifecycle methods are called in the correct order (setup() needs to be called before this method)
- Please check that your test code waits for the promises returned from lifecycle methods to complete before calling the next one
- To learn more about what is happening during your pact run, try setting logLevel: 'DEBUG'
2) "after all" hook in "GraphQL example"
0 passing (11ms)
2 failing
1) GraphQL example
"before all" hook in "GraphQL example":
Error: listen EADDRNOTAVAIL: address not available 172.28.0.4:1234
at Server.setupListenHandle [as _listen2] (node:net:1355:21)
at listenInCluster (node:net:1420:12)
at GetAddrInfoReqWrap.doListen (node:net:1559:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:74:8)
2) GraphQL example
"after all" hook in "GraphQL example":
Error: The pact mock service wasn't running when finalize was called
at Pact.finalize (node_modules/@pact-foundation/src/httpPact.ts:183:9)
at Context.<anonymous> (src/consumer.spec.ts:33:26)
at processImmediate (node:internal/timers:466:21)
Édouard Lopez
03/23/2022, 4:51 PMwithRequest
). We are in the process of deploying Pact internally and people are this for the wrong reason (e.g. copy/pasting code)
https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/test/consumer.spec.js#L180Bernard Baker
03/24/2022, 11:52 AMpact-node@10.17.2: Pact Binary Error: WARN: No content type found, performing text diff on body
Any ideas? After a google search I wasn't able to work out how to remove this error from the output of the test run.Damian
03/28/2022, 7:35 PM