https://pact.io logo
Join SlackCommunities
Powered by
# pact-js
  • m

    Mrigendra Ranjan

    07/27/2022, 1:28 PM
    So I have been trying to run pact-verify stage in my gitlab pipeline and I am facing below errors. Has anyone faced anything similar?
    Error: Error relocating /builds/app/node_modules/@pact-foundation/pact-core/build/Release/libpact_ffi.so: __vsnprintf_chk: symbol not found
    I have tried with beta60 and beta62 as well but I don’t think its an issue with the version.
    t
    m
    a
    • 4
    • 23
  • a

    Akash Sharma

    07/28/2022, 7:51 AM
    Hi guys, at Provider sider verification I have two requests to be verified. One is Post and other is get. I want to read ‘id’ from Post response and fed it to get request (get by id). How do I read response using requestFilter?
    t
    m
    • 3
    • 7
  • p

    pollet

    07/28/2022, 2:46 PM
    hi guys , can any one advice me .. i am new in pact and i want to make a contract testing between two micro-services which is in go language it's ok to write pact in Javascript as i experience in javascript not in go ?
    m
    • 2
    • 4
  • y

    Yair Shkedi

    07/29/2022, 1:17 PM
    I have 2 questions: 1 - I saw that there isn’t an option to verify an empty array, but I think there are some cases that it should be checked, for example: Assume you have the following get request: getFieldsByCountry the response is
    [{ l1: fields[{k1, v1}] ,
    l2: fields[]}
    In other words, what about the case of API that has children that has attrbiute as value with array type, but some of the array could be an empty array, I think this is a common case saw this post as well https://stackoverflow.com/questions/61772433/how-to-verify-pact-when-data-returns-items-with-or-without-children-filled-in-o and I understood the issue if min value would be 0, but from the other case, i think it is a common case that couldn’t be checked 2 - How can I verify a request with a dynamic id (url param). I looked into the documentation, and didn’t see a way to do that. For example, I have an api that generate some request and the response is the id, then I want to call to a get request, by the id (the id is a url param) (the id is created dynamically)
    t
    d
    m
    • 4
    • 20
  • h

    Harris Lee

    08/01/2022, 4:42 AM
    Hello, as v3 is no longer beta, is it changed to
    jest-pact
    as well? https://github.com/pact-foundation/jest-pact/blob/pact-js-v3/README.md#pact-js-v3 what is right usage for jest-pact now?
    m
    • 2
    • 1
  • h

    Harris Lee

    08/01/2022, 5:36 AM
    I dont know where to post rust error , but
    thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', pact_matching/src/headers.rs:22:45
    what is meaning?
  • m

    Matt (pactflow.io / pact-js / pact-go)

    08/01/2022, 5:40 AM
    Perhaps tells us what you're doing to get this problem and we can help
    h
    s
    • 3
    • 31
  • d

    Dmitry Munda

    08/01/2022, 4:17 PM
    hi! i’m getting
    Timeout waiting for verification process to complete
    i found this https://docs.pact.io/slack/pact-js.html#1586998747.127100 do i get it right, i need something like this ?
    Copy code
    return new MessageProviderPact({
    ...
            timeout: 60000,
    ...
        }).verify()
    }
    m
    • 2
    • 3
  • d

    Dwiparna Pal

    08/02/2022, 1:58 PM
    Hi, I'm doing a POC on pactflow for js with SQS. The sample I'm following https://github.com/pactflow/example-consumer-js-sns/blob/master/__tests__/unit/handlers/product.service.pact.test.js. But everything is not very clear to me. Can anyone please help me. Thanks
    m
    s
    • 3
    • 14
  • d

    Dwiparna Pal

    08/03/2022, 3:27 PM
    Hi, can anyone give me some example of aws SQS event pact provider examples. How do I generate the pacts for such events. Thanks
    y
    • 2
    • 1
  • q

    Qingyuan Liu

    08/08/2022, 5:40 AM
    Hi team, can I test the communication between a nodejs project and spring project? Is there any sample project about testing in different code stacks?
    m
    • 2
    • 2
  • r

    Remigijus Mažulis

    08/08/2022, 5:45 AM
    Good morning, could anyone help me to add more interactions on consumer side? I've done according to example and it works with one interaction, but I cannot figure out the way to add more interactions 🤔
    m
    b
    t
    • 4
    • 9
  • l

    Laura Cabantous

    08/08/2022, 11:20 AM
    Hi there, I'm trying to run a test scenario where a parameter is passed in an invalid format (and it should throw a 400), but it fails with the error message
    with 30000 ms timeout for Pact
    . I've tried to increase the timeout (quite significantly but it still fails with the same message). Is there any way to check why it times out? It seems due to a promise that doesn't resolve... Also it seems to be specifically when looking to get the provider to respond with status 400 🤔 Code snippet in 🧵
    m
    y
    • 3
    • 10
  • h

    Heera Singh

    08/08/2022, 11:54 AM
    Hello, Good Afternoon, I had written one consumer test for
    200
    status and it worked well for me, my next task is to validate
    401 Unauthorised
    state, but my consumer test is failing https://codeshare.io/wnEOZD, could anyone point me to right direction.
    y
    t
    m
    • 4
    • 12
  • a

    Arnon Ram

    08/09/2022, 8:41 AM
    Hi, is it possible to use
    providerState
    to change the body (or part of it) of a POST request? in the consumer side i add:
    Copy code
    body: fromProviderState('${actualyPayload}', samplePayload),
    and in the relevant
    stateHandler
    on the provider side i added:
    Copy code
    setup: () => {
                return Promise.resolve({ actualPayload: payload });
              },
    But pact still seems to send the original payload
  • m

    Matt (pactflow.io / pact-js / pact-go)

    08/09/2022, 8:42 AM
    No you can't. What's the use case?
    a
    t
    • 3
    • 16
  • m

    Matt (pactflow.io / pact-js / pact-go)

    08/09/2022, 8:42 AM
    Request filters are possibly your answer
  • m

    Matt (pactflow.io / pact-js / pact-go)

    08/09/2022, 8:43 AM
    But I'd like to know why, it's a dangerous thing to do
  • h

    Heera Singh

    08/09/2022, 9:08 AM
    Hi, when I am trying to access
    providerBaseUrl
    in provider test by passing value directly
    process.env.BASE_URL
    it does not recognize it, it says
    TypeError: Invalid URL
    while passing url in string works https://codeshare.io/BAQW7b, any idea what I am missing.
    m
    • 2
    • 7
  • a

    Abdurahman Hijazi

    08/11/2022, 11:26 AM
    Hi, I'm writing pact tests for my team. One of the interactions I'm writing expects a jwt. How do I test that the decoded jwt matches what I expect it to be
  • m

    Matt (pactflow.io / pact-js / pact-go)

    08/11/2022, 11:51 AM
    howtoauth
    a
    • 2
    • 10
  • a

    Adam Witko

    08/11/2022, 2:26 PM
    Has anyone seen any issues upgrading from v9 to v10, and the TS type changes for customProviderHeaders for the Verifier requires it to now be
    customProviderHeaders: { [key: string]: string }
    . Not a problem to swap from the v9 array to v10, but this then pumps out an error:
    t
    • 2
    • 11
  • j

    Joel

    08/12/2022, 6:59 AM
    Hi, is it possible to use PactV3 to test GraphQL queries in Pact-JS on the consumer side? According to the updated docs (thank you for your effort Matt) this is not possible, but I thought what shouldn't be a problem, is to test the POST method with the plain request body. But as soon as I add a body to the
    withRequest
    method, I get a 500 from the mock server what makes debugging really hard (pushing this issue as it makes it hard to find out whats going on). Is it intended to stick to PactV2 for GraphQL testing or is it possible to create a Pact with a body for the request with PactV3? Just asking here to see if i missed something, otherwise I think I will open a issue with an example.
    m
    • 2
    • 7
  • a

    Adam Witko

    08/12/2022, 10:14 AM
    Hey hey has it been spotted that 10.1.0 (similar for all 10.x.x releases) will publish verification results even when
    publishVerificationResult
    is false panic kermit ?
    m
    y
    t
    • 4
    • 42
  • a

    Adam Witko

    08/12/2022, 10:18 AM
    Also, verification fails if there are no pacts to verify when it used to pass with ^9.0.0. The provider does exist, there but given the consumerVersionSelectors there are no pacts to verify yet:
    Copy code
    {
          publishVerificationResult: false,
          provider: 'delivery-promise-service',
          providerBaseUrl: '<http://localhost:8000>',
          providerVersion: '09fe6815',
          providerBranch: 'DP-2086-state-handlers-for-rob-contracts',
          pactBrokerUrl: '<https://pact-broker.dunelm.io/>',
          enablePending: true,
          consumerVersionSelectors: [
            { mainBranch: true },
            { deployedOrReleased: true },
            { matchingBranch: true }
          ],
          customProviderHeaders: { 'x-apigateway-event': '""', 'x-apigateway-context': '""' }
    }
    m
    y
    • 3
    • 8
  • a

    Adam Witko

    08/12/2022, 3:55 PM
    https://github.com/pact-foundation/pact-js-core/issues/392 created this to fix a validation issue for ^10.x.x of pact-js (13.7.3 of pact-js-core) where the validation for customProviderHeaders fails and doesn't match the types. I think there may be other issues given the test coverage around validateOptions.ts, but I have to finish up for the day so I don't have the time to look at it now @Matt (pactflow.io / pact-js / pact-go)
    m
    • 2
    • 1
  • p

    Prateek Madapurmath

    08/15/2022, 1:17 AM
    hello! not sure if this has been asked here before already, but i’ve been having issues running consumer tests with PactV3. i’ve set up my test file as such:
    Copy code
    const provider = new PactV3({ consumer, provider, dir, port: 1234 })
    describe('test 1', () => {
      test('should pass', () => {
        provider
          .given('valid user session')
          .uponReceiving('request')
          .withRequest({ 
            method: 'POST', 
            path: '/my-url', 
            headers: { custom_header }, 
            body: reqBody
          })
          .willRespondWith({
            status: 200,
            headers: reponseHeaders,
            body: like(exampleBody)
          })
        
        await provider.executeTest(async mockService => {
          myApi.configureUrl(mockService.url)
          const apiResp = await <http://myApi.post|myApi.post>({ 
            headers: { custom_header },
            data: reqBody,
          })
        })
      })
    })
    however, the above test fails with
    The following request was expected but not received
    and then it displays the request that I have defined under
    withRequest
    i’m not sure what setup i got wrong
    t
    m
    • 3
    • 45
  • m

    Maxim Filimonov

    08/16/2022, 7:59 AM
    Is
    V3Interaction
    compatible with
    ApolloGraphqlInteraction
    ? I’m getting type errors:
    Copy code
    Type 'ApolloGraphQLInteraction' is not assignable to type 'V3Interaction'.
      Types of property 'uponReceiving' are incompatible.
        Type '(description: string) => ApolloGraphQLInteraction' is not assignable to type 'string'.ts(2322)
    m
    t
    • 3
    • 7
  • h

    Heera Singh

    08/16/2022, 2:17 PM
    Hi Team, I am using
    jest
    with
    pact-js
    and found when I try to run provider tests which has a wrong mapping with consumer contract file or contract file does not exist. It still shows
    Test Suites
    and
    Tests
    as passed. Of-course it does not show pact execution status (interaction, provider state, request, response) in run, but I was expecting
    Test Suites
    and
    Tests
    status as failed. Is there a way to achieve it? tried to see the logs as well but did not found any Error level logs there.
    m
    • 2
    • 7
  • h

    Heera Singh

    08/16/2022, 2:25 PM
    Hi Team, I have one more query to ask here. I wanted to validate one response attribute which is like
    "completed": "2022-01-21T07:58:42.196238Z",
    I used matcher like
    completed: Matchers.iso8601DateTimeWithMillis("2022-01-21T07:58:26.251019Z"),
    to validate it. In some cases it gives me value
    null
    instead of date format string value. I know in pact we should try to get that state in provider states if we want to check exact case. still looking if there is another way to validate it.
    m
    • 2
    • 1
1...567...14Latest