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

    John Williams

    07/05/2022, 11:59 PM
    so just a quick question, this beta 3 version "fromProviderState" is the only platform that is available on is JS?
    u
    • 2
    • 5
  • c

    Cody Jenkins

    07/06/2022, 7:19 AM
    Hey everyone! I just encountered this error with the most recent version (4 hours ago) of pact-node 10.17.5:
    Copy code
    $ yarn add @pact-foundation/pact-node@10.17.5
    yarn add v1.22.19
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [3/4] Linking dependencies...
    [4/4] Building fresh packages...
    error /tmp/tmp.CovE6vLZ5q/node_modules/@pact-foundation/pact-node: Command failed.
    Exit code: 1
    Command: node postinstall.js
    Arguments: 
    Directory: /tmp/tmp.CovE6vLZ5q/node_modules/@pact-foundation/pact-node
    Output:
    Installing Pact Standalone Binary for linux.
    Downloading Pact Standalone Binary v1.89.02-rc1 for platform linux from <https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.89.02-rc1/pact-1.89.02-rc1-linux-x86_64.tar.gz>
    Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set 'pact_do_not_track: true' in your package.json 'config' section.
    Downloaded 26.57%...
    Downloaded 84.62%...
    Finished downloading binary to /tmp/tmp.CovE6vLZ5q/node_modules/@pact-foundation/pact-node/standalone/pact-1.89.02-rc1-linux-x86_64.tar.gz
    Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error: Error while installing binary: Checksum file missing from standalone directory. Aborting.
        at throwError (/tmp/tmp.CovE6vLZ5q/node_modules/@pact-foundation/pact-node/standalone/install.js:42:11)
        at /tmp/tmp.CovE6vLZ5q/node_modules/@pact-foundation/pact-node/standalone/install.js:327:16
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    info Visit <https://yarnpkg.com/en/docs/cli/add> for documentation about this command.
    👋 3
    b
    y
    +2
    • 5
    • 21
  • b

    Billal

    07/06/2022, 10:44 AM
    Hello. I’m not sure if this is the correct channel but when running the verify job, I am getting this error:
    No pacts were found for the consumer versions selected
    - This is totally fine however, the job still passes. Is there a way to make it fail in such cases? Once again, apologies if this is in the wrong place 🙂
  • h

    Harris Lee

    07/07/2022, 4:18 AM
    sorry somehow, I cannot make anymore thread comment to original post lol has anyone have idea?
    GLIBC_2.25
    version complaints from
    node-14,16:slim
    docker image for pact
    v3 beta
    ?
    m
    • 2
    • 4
  • c

    Cody Jenkins

    07/07/2022, 7:38 AM
    Hey again all, sorry for another end-of-day issue (and sorry for not providing more detail with it) but something is not quite right with
    @pact-foundation/pact
    version
    9.18.1
    . My provider tests are failing because the incoming request body is being mangled. Rather then sending through this:
    Copy code
    {
      "foo": "bar"
    }
    it's sending through this:
    Copy code
    {
      "{\"foo\":\"bar\"}": ""
    }
    This happens in
    9.18.1
    but not
    9.17.3
    . I have to stop for the day but I can provide more details on this tomorrow (including pacts and more detail on what versions are affected). I thought at least posting this might jog someone's memory about something
    👋 1
    m
    • 2
    • 11
  • p

    Prasad

    07/07/2022, 4:07 PM
    Hello All, I am trying to write an interaction where I need to provide custom headers. But this doesn't seem to be working. Am I doing something wrong here?
    m
    • 2
    • 3
  • a

    Abdurahman Hijazi

    07/07/2022, 4:19 PM
    Quick q: Are there any ways you can add objects in the pact file?
    m
    • 2
    • 14
  • p

    Prasad

    07/08/2022, 9:08 AM
    Hello All, Anyone has example of writing interaction for mulitpart/form-data upload?
    m
    • 2
    • 2
  • a

    Alexandre

    07/08/2022, 2:23 PM
    Hello All, I'm trying the sample of example-bi-directional-consumer-mountebank on windows 10. It run fines, but the pact file produce by the test does not contains any interactions in it, and eventually the publish scripts submit a blank contract on the pact-broker
    Copy code
    {
      "consumer": {
        "name": "pactflow-example-bi-directional-consumer-mountebank"
      },
      "provider": {
        "name": "pactflow-example-bi-directional-provider-dredd"
      },
      "interactions": [],
      "metadata": {
        "pactSpecification": {
          "version": "2.0.0"
        }
      }
    }
    Do you know how to fix ? 🙂
    • 1
    • 2
  • j

    json

    07/08/2022, 9:01 PM
    Hey! Sorry if this is a somewhat novice question, but I'm very new to JS/TS and trying to help another team out: We are using axios to perform REST requests in our client classes, and the base_url is populated via an import from another module that handles environment variables (as constants). So what's the best way to change the base_url to point at the pact mock server?
    t
    • 2
    • 2
  • h

    Harris Lee

    07/11/2022, 2:08 AM
    Hello quick question about
    stateHandler
    , we will use real provider side API to generate data, however, when stateHandler is failed, it does not execute the other tests, what is good practice workaround in here? for example, some verifier from provider side doesnt need stateHandler, if state handler somehow error/fail, shall we execute rest of them? any good tip for jest setup for provider? we use
    jest-each
    to loop all contract in provider side.
    Copy code
    each(needToBeVerified).it('should verify the expectations of %p Graphql', contractName => {
          return new Verifier(createOptions(`${contractName}-provider`)).verifyProvider().then(output => {
            if (output.includes('Diff')) {
              console.log(output)
              throw new Error(`${contractName} contract test error`)
            }
          })
    t
    • 2
    • 9
  • h

    Harris Lee

    07/13/2022, 1:44 AM
    Hello , for pact-js
    v3
    config,
    Copy code
    publishVerificationResult: true
    it seems even we set
    false
    it always pushed to the pactflow(broker) is that known issue? or only me lol ?
    m
    • 2
    • 3
  • r

    Ravindra Dhaka

    07/13/2022, 3:50 PM
    Hi All, did anyone integrated the pact-js in gitlab/github ci/cd pipeline (node project)??
    t
    • 2
    • 27
  • n

    Noor Hashem

    07/13/2022, 5:39 PM
    Hi All, i'm new here to pact and am very excited to get using it!! I am curious however about authentication. I have already created a contract from a react consumer side and published the contract to pactflow. I am now on the provider side (Nest JS) and need to confirm that the provider can provide what is in the contract. The exact Interaction is simply getting a users information, but the user needs to be logged in for us to get the information. So how would I be able to have pact authenticate so that it can reach the endpoint on the provider side and confirm the contract is good? Please let me know if you would like me to provide any additional information.
    m
    s
    • 3
    • 5
  • m

    Marcello Rigan

    07/19/2022, 1:33 PM
    Hello while running tests in our git pipeline i ran into this "[2022-07-19 121219.353 +0000] INFO (579 on runner-9srzqayz-project-119-concurrent-2): pact@9.18.1: Setting up Pact with Consumer "BBX" and Provider "INT" 134 using mock service on Port: "2134" 135[2022-07-19 121219.357 +0000] ERROR (579 on runner-9srzqayz-project-119-concurrent-2): pact@9.18.1: error making http request: axios_1.default is not a function"
    m
    • 2
    • 5
  • h

    Harris Lee

    07/20/2022, 12:32 AM
    has anyone had an issue with JS memory issue? with
    pact v3 node 18 slim
    container? It kept getting memory issue from 2gb so I had bumped up to 4gb, but still get some issues. I did not face any issue with
    pact v2 with node 14 slim
    from 2gb memory, all tests are running passed but getting memory error
    Copy code
    <--- JS stacktrace --->
     
    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
     1: 0xb65a10 node::Abort() [/usr/local/bin/node]
     2: 0xa761b5 node::FatalError(char const*, char const*) [/usr/local/bin/node]
     3: 0xd5713e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
     4: 0xd574b7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
     5: 0xf34545  [/usr/local/bin/node]
     6: 0xf35448 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
     7: 0xf45953  [/usr/local/bin/node]
     8: 0xf467c8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
     9: 0xf2112e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
    10: 0xf224f7 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
    11: 0xf02a40 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/local/bin/node]
    12: 0xefa4b4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/usr/local/bin/node]
    13: 0xefc768 v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString(int, v8::internal::AllocationType) [/usr/local/bin/node]
    14: 0xf05d2d v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [/usr/local/bin/node]
    15: 0xd661a3 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/usr/local/bin/node]
    16: 0xbba616 v8::MaybeLocal<v8::Value> node::ToV8Value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(v8::Local<v8::Context>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, v8::Isolate*) [/usr/local/bin/node]
    17: 0xc0f4b5  [/usr/local/bin/node]
    18: 0xc1597a  [/usr/local/bin/node]
    19: 0x167e06f  [/usr/local/bin/node]
    Aborted (core dumped)
    so I bumped up memory to 4gb but it still sometimes got error
    Copy code
    spawn ENOMEM
     
          at spawn (node_modules/cross-spawn/index.js:12:24)
          at Spawn.Object.<anonymous>.Spawn.spawnBinary (node_modules/@pact-foundation/pact-core/src/spawn/spawn.ts:46:22)
          at Server.Object.<anonymous>.AbstractService.spawnBinary (node_modules/@pact-foundation/pact-core/src/service.ts:245:18)
          at Server.Object.<anonymous>.AbstractService.start (node_modules/@pact-foundation/pact-core/src/service.ts:165:28)
          at node_modules/@pact-foundation/src/httpPact/index.ts:277:19
          at Pact.Object.<anonymous>.Pact.startServer (node_modules/@pact-foundation/src/httpPact/index.ts:276:12)
          at node_modules/@pact-foundation/src/httpPact/index.ts:94:24
    Copy code
    The pact mock service wasn't running when verify was called
     
          at Pact.Object.<anonymous>.Pact.verify (node_modules/@pact-foundation/src/httpPact/index.ts:145:9)
          at Object.<anonymous> (node_modules/jest-pact/index.js:26:45)
    anyone had same issue?
    t
    • 2
    • 27
  • j

    json

    07/20/2022, 7:41 PM
    Sorry, this is probably a super basic question, but I cannot figure out how to get Matchers to work with my typescript consumer contract test. I have a contract test that is working, but I'm manually setting a UUID which the provider will generate, so I need the contract to accept any valid UUID. But when I change the element in my expected body from
    Copy code
    id: "ce118b6e-d8e1-11e7-9296-cec278b6b50a"
    to
    Copy code
    id: Matchers.uuid("ce118b6e-d8e1-11e7-9296-cec278b6b50a")
    I am now getting:
    Copy code
    Object {
    -   "id": Object {
    -     "data": Object {
    -       "generate": "ce118b6e-d8e1-11e7-9296-cec278b6b50a",
    -       "matcher": Object {
    -         "json_class": "Regexp",
    -         "o": 0,
    -         "s": "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$",
    -       },
    -     },
    -     "getValue": [Function getValue],
    -     "json_class": "Pact::Term",
    -   },
    +   "id": "ce118b6e-d8e1-11e7-9296-cec278b6b50a",
      }
    
    > 92 |         expect(response).toEqual(responseData)
         |                          ^
    This is all inside a
    pactWith
    block, because this is using the jest-pact library.
    m
    t
    • 3
    • 9
  • m

    MiKey

    07/20/2022, 9:03 PM
    Apologize if this isn't the right channel, just picked one of the 2 in play....I am having an issue between a consumer using pact-js:0.9.4 and a provider using junit5spring:4.3.7 where the verification is failing saying:
    Copy code
    Header:
    Content-Type: Expected a header 'Content-Type' but was missing
    Body:
    Expected a response type of 'application/json' but the actual type was 'null'
    I have verified that the header is in the contract on the consumer, and that the provider is producing a content-type...any insight what might be going on here?
    m
    u
    • 3
    • 15
  • z

    Zhaopeng XUAN

    07/22/2022, 8:34 AM
    Hey team, may I ask pact-js is in v4 pact or v3 pact? in pact-jvm it mentioned that from v4.3.x it can support pact plugin, may I ask for pact-js do we also support plugins? thanks a lot . (since we need to add our gRPC plugin) cc: @Vadik Ozhgibesov
    m
    • 2
    • 1
  • h

    Harley Thomas

    07/23/2022, 2:22 AM
    Hey team, In my application, I require request headers that are derived from the current date/time and a private key. I am now experiencing intermittent timing issues in my consumer tests because of this, I set
    withRequest
    with a header that is calculated at run time, but then my actual application code executes a second or two later, and generates a slightly different header since the time is off by a second or two. I tried to use Matchers, but then those matches get sent to my provider within provider verification and fail since it is a malformed header and the service denies the request. Is there a workaround here? Can I specify a Matcher within
    withRequest
    but use the actual header from the application code to verify against the provider? New to pactflow and contract testing in general so apologies in advance! Any help would be greatly appreciated.
    m
    • 2
    • 3
  • y

    Yair Shkedi

    07/25/2022, 9:21 PM
    👋 Hello, team! I defined “@pact_foundation_greet/pact”: “9.18.1", on my package json, install it, wrote some tests, run and all is great. I am using mac. in my CI, the npm install (also for the pact) happens inside docker (node:16.16.0-bullseye-slim), In the installation I am getting the following error npm ERR! code 1 npm ERR! path /usr/src/app/node_modules/@pact-foundation/pact-node npm ERR! command failed npm ERR! command sh -c node postinstall.js npm ERR! Installing Pact Standalone Binary for linux. npm ERR! Downloading Pact Standalone Binary v1.89.02-rc1 for platform linux from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.89.02-rc1/pact-1.89.02-rc1-linux-x86_64.tar.gz npm ERR! Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set ‘pact_do_not_track: true’ in your package.json ‘config’ section. npm ERR! Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.89.02-rc1/pact-1.89.02-rc1-linux-x86_64.tar.gz: Error: Error while installing binary: Error: EACCES: permission denied, open ‘/root/.npmrc’ npm ERR! at throwError (/usr/src/app/node_modules/@pact-foundation/pact-node/standalone/install.js4211) npm ERR! at /usr/src/app/node_modules/@pact-foundation/pact-node/standalone/install.js32716
    m
    • 2
    • 11
  • y

    Yair Shkedi

    07/25/2022, 9:21 PM
    I looked into the .npmrc permission and I don’t see any issue there (for the worst case, i gave it 777 access)
  • y

    Yair Shkedi

    07/25/2022, 9:22 PM
    i tried to downgrade the version to 9.17.3 and getting the same error
  • y

    Yair Shkedi

    07/25/2022, 9:22 PM
    locally, it works great
  • y

    Yair Shkedi

    07/25/2022, 9:22 PM
    didn’t see any usful answer on the internet, would like to get your help
  • h

    Harris Lee

    07/27/2022, 12:14 AM
    hello, can I get some reference document point to resolve this error?
    The property 'all' is not a valid property of ConsumerVersionSelector. Allowed properties are tag, latest, consumer, deployedOrReleased, deployed, released, environment, fallbackTag, branch, mainBranch, matchingBranch)
    after I update to v3, I got this message, can I get some guideline please?
    m
    • 2
    • 5
  • h

    Harris Lee

    07/27/2022, 5:44 AM
    for provider side verification, I got
    Copy code
    has status code 200 (OK)
           includes headers
             "Content-Type" with value "application/json" (OK)
          has a matching body (OK)
    then failure
    Copy code
    1.1) has a matching body
    expected 'application/json;charset=utf-8' body but was 'application/json'
    
    1.2) includes header 'Content-Type' with value 'application/json; charset=utf-8'
    Expected header 'Content-Type' to have value 'application/json; charset=utf-8' but was 'application/json'
    I am little bit confused. lol consumer pact response and request headers are
    Copy code
    "headers": {
              "Content-Type": "application/json"
            },
    m
    t
    • 3
    • 40
  • h

    Harris Lee

    07/27/2022, 5:46 AM
    where should I look at to fix?
  • a

    Alan Boshier

    07/27/2022, 8:18 AM
    Hi running beta58 and trying to debug a consumer contract test where the URL path is matching when it shouldn't be
    Copy code
    [2022-07-27T08:00:39Z INFO  pact_mock_server::hyper_server] Received request HTTP Request ( method: GET, path: /foo/1/bar, query: None, headers: Some({"accept": ["application/json"], "authorization": ["Bearer undefined"], "user-agent": ["node-fetch/1.0 (+<https://github.com/bitinn/node-fetch>)"], "accept-encoding": ["gzip", "deflate"], "connection": ["close"], "host": ["127.0.0.1:52198"]}), body: Empty )
    
    [2022-07-27T08:00:39Z INFO  pact_matching] comparing to expected HTTP Request ( method: GET, path: /fooBlah/1/bar, query: None, headers: Some({"Accept": ["application/json"]}), body: Missing )
    [2022-07-27T08:00:39Z INFO  pact_mock_server::hyper_server] Request matched, sending response HTTP Response ( status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(266 bytes, application/json) )
    I'm looking for strings like
    comparing to expected HTTP Request
    in the pact and pact-core codebase but not having any luck - could someone point me at where these are? [Some GLIBC-related blockers prevent me moving to beta62 at this time]
    m
    • 2
    • 6
  • a

    Alan Boshier

    07/27/2022, 8:22 AM
    P.S. ^^^ I think the issue is related to using
    fromProviderState('/fooBlah/{id}/bar', '/fooBlah/1/bar')
    when specifying a path matcher, as using a raw matcher causes the URL to not be matched (as expected)
1...456...14Latest