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

    Sebastian Suarez

    03/28/2022, 7:59 PM
    Hello Team 👋😎, a question, I am trying to run my pact project on a mac machine with big sur 11.6.2 operating system, and I am having problems on the provider side, pact throws a generic error, I have not found the possible cause; the log is the following, Do you know why it could have this behavior?:
    m
    • 2
    • 6
  • a

    Adrian Ernst

    03/30/2022, 1:03 PM
    Hello everyone im currently writing a pact test for an endpoint that returns a file i want to download. I can't seem to find a matcher for binary data and adding binary to Matchers.somethinglike() doesnt seem to work. Is the right practice here to just not add a body to the willRespondWith Object?
    m
    • 2
    • 2
  • r

    Radha

    03/30/2022, 10:06 PM
    consumer@1.0.0 pacts C:\UIEN-Local\pact-test\pact-test
    mocha --recursive "tests/*.pact.js" --timeout 100000
    [2022-03-30T220407.287Z] INFO: pact-node@10.9.4/13532 on PC0X2B10: Creating Pact Server with options: {"consumer":"React","cors":false,"dir":"C:\\UIEN-Local\\pact-test\\pact-test\\pacts","host":"127.0.0.1","log":"C:\\UIEN-Local\\pact-test\\pact-test\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false} Consumer Test [2022-03-30T220408.891Z] INFO: pact@9.11.0/13532 on PC0X2B10: Setting up Pact with Consumer "React" and Provider "token" using mock service on Port: "1234" √ OK response Pact verification failed! Actual interactions do not match expected interactions for mock MockService. Missing requests: GET /modules See C:/UIEN-Local/pact-test/pact-test/logs/pact.log for details. (node:13532) UnhandledPromiseRejectionWarning: AssertionError: expected 'OK ' to equal 'OK' at C\UIEN Local\pact test\pact test\tests\consumer.pact.js55:47 at processTicksAndRejections (internal/process/task_queues.js975) (node:13532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
    --unhandled-rejections=strict
    (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:13532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 1) "after each" hook for "OK response" [2022-03-30T220408.973Z] INFO: pact@9.11.0/13532 on PC0X2B10: Pact File Written [2022-03-30T220408.973Z] INFO: pact-node@10.9.4/13532 on PC0X2B10: Removing Pact process with PID: 9936 [2022-03-30T220409.152Z] INFO: pact-node@10.9.4/13532 on PC0X2B10: Deleting Pact Server with options: {"consumer":"React","cors":false,"dir":"C:\\UIEN-Local\\pact-test\\pact-test\\pacts","host":"127.0.0.1","log":"C:\\UIEN-Local\\pact-test\\pact-test\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false} 1 passing (2s) 1 failing 1) Consumer Test "after each" hook for "OK response": Error: Pact verification failed - expected interactions did not match actual. at new VerificationError (node_modules\@pact-foundation\pact\errors\verificationError.js1942) at C:\UIEN-Local\pact-test\pact-test\node_modules\@pact-foundation\pact\httpPact.js10223 at processTicksAndRejections (internal/process/task_queues.js975) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! consumer@1.0.0 pacts:
    mocha --recursive "tests/*.pact.js" --timeout 100000
    npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the consumer@1.0.0 pacts script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\radha.danthuluri\AppData\Roaming\npm-cache\_logs\2022-03-30T22_04_09_197Z-debug.log
    m
    • 2
    • 2
  • g

    GitHub

    04/01/2022, 7:24 AM
    Release - Release v10.0.0-beta.59 New release published by github-actions[bot] 10.0.0-beta.59 (2022-04-01) Fixes and Improvements • content type detection now considers matchers (069da08) • e2e tests were verifying the wrong pacts (1999f2d) • infer content type from headers, prevent non JSON-able state parameters (2a6acf3) • update to latest core (51c4c52) pact-foundation/pact-js
    m
    a
    • 3
    • 2
  • a

    Alan Alie

    04/01/2022, 10:09 AM
    Hi all, I’ve previously written pact tests using axios as the http handler but the consumer app itself uses fetch (from node-fetch) instead. I’ve tried to switch to using fetch but hit problems. I understand that using jest-pact is a possible solution so I’ve implemented the following example:
    Copy code
    import { URL } from 'url';
    
    import { Matchers } from '@pact-foundation/pact';
    import { HTTPMethod } from '@pact-foundation/pact/src/common/request';
    import { pactWith } from 'jest-pact';
    import fetch from 'node-fetch';
    
    jest.setTimeout(30000);
    
    pactWith({ consumer: 'aggregator', provider: 'theme_provider' }, (provider) => {
        describe('Theme related end points', () => {
            it('Request to save themes', async () => {
                const url = new URL(`${provider.mockService.baseUrl}/themes-service/themes`);
    
                const { validateExample } = Matchers;
    
                const interaction = {
                    state: 'Request to save themes',
                    uponReceiving: 'Request to save themes',
                    withRequest: {
                        method: <http://HTTPMethod.POST|HTTPMethod.POST>,
                        path: url.pathname,
    
                        headers: { Accept: 'application/json' },
                    },
                    willRespondWith: {
                        status: 200,
                        headers: { 'Content-Type': 'application/json' },
                        body: {
                            results: [{ handle: 'abc', result: 'Created' }],
                        },
                    },
                };
    
                await provider.addInteraction(interaction);
                const result = await fetch(`${provider.mockService.baseUrl}/themes-service/themes`, {
                    method: <http://HTTPMethod.POST|HTTPMethod.POST>,
                    headers: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json',
                    },
                });
    
                expect(await result.json()).toEqual({
                    results: [
                        {
                            handle: 'abc',
                            result: 'Created',
                        },
                    ],
                });
            });
        });
    });
    Unfortunately, I get the following error:
    Copy code
    FAIL  __pact__/fetch2.pact.spec.ts (10.793 s)
      Pact between aggregator and theme_provider
        with 30000 ms timeout for Pact
          Theme related end points
            ✕ Request to save themes (59 ms)
    
      ● Pact between aggregator and theme_provider › with 30000 ms timeout for Pact › Theme related end points › Request to save themes
    
        FetchError: invalid json response body at  reason: Unexpected end of JSON input
    
          42 |             });
          43 |
        > 44 |             expect(await result.json()).toEqual({
             |                    ^
          45 |                 results: [
          46 |                     {
          47 |                         handle: 'abc',
    
          at node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:273:32
          at Object.<anonymous> (__pact__/fetch2.pact.spec.ts:44:20)
    If I remove
    await
    from the offending line of code then the test fails because the response promise never gets fulfilled 😕
    Copy code
    FAIL  __pact__/fetch2.pact.spec.ts (12.368 s)
      Pact between aggregator and theme_provider
        with 30000 ms timeout for Pact
          Theme related end points
            ✕ Request to save themes (65 ms)
    
      ● Pact between aggregator and theme_provider › with 30000 ms timeout for Pact › Theme related end points › Request to save themes
    
        expect(received).toEqual(expected) // deep equality
    
        - Expected  - 8
        + Received  + 1
    
        - Object {
        -   "results": Array [
        -     Object {
        -       "handle": "abc",
        -       "result": "Created",
        -     },
        -   ],
        - }
        + Promise {}
    
          42 |             });
          43 |
        > 44 |             expect(result.json()).toEqual({
             |                                   ^
          45 |                 results: [
          46 |                     {
          47 |                         handle: 'abc',
    
          at Object.<anonymous> (__pact__/fetch2.pact.spec.ts:44:35)
    What am I missing or overlooking? I'd be really grateful for any assistance on this problem 🙂
    m
    • 2
    • 17
  • a

    Artur Neumann

    04/04/2022, 5:45 AM
    with v10.0.0-beta.59 it seems not to be possible to have in one interaction multiple provider states with the same name. That was possible in .36. Is that a bug or a feature? My use-case is to create multiple files. So I call multiple times `
    Copy code
    provider.given('file exists', { username, password, fileName: resource })
    but in the JSON I only have one providerstate with that name
    Copy code
    "providerStates": [
            {
              "name": "the user is recreated",
              "params":...
            },
            {
              "name": "file exists",
              "params": {
                "fileName": "testFolder/文件.txt",
                "password": "test123",
                "username": "test123"
              }
            },
            {
              "name": "resource is shared",
              "params": ...
            }
          ]
    Making the names of provider states individual makes them appear in the JSON, but that would mean I would also have to have an individual state definition in the provider tests (stateHandlers)
    m
    u
    • 3
    • 16
  • a

    Arthur Toper

    04/04/2022, 2:33 PM
    hi, i have a few questions / thoughts regarding GraphQL contract testing with Pact (JS), and was wondering whether this would be a good place to put them, or whether another channel might be preferred?
    👋 1
    y
    • 2
    • 3
  • a

    Arthur Toper

    04/04/2022, 4:00 PM
    we're looking at using Pact to give us nice test separation between our front-end clients and our back-end, which provides a GraphQL API for them to use. at the moment, from having experimented with the GraphQLInteraction class in the Pact JS library, it appears as if fairly complete GraphQL query strings need to be provided in order for the Pact mock API server to return the correct response. i have managed to get this working by formatting the query in precisely the right way (e.g.
    ... on
    rather than
    ...on
    , etc.), according to the GraphQL client library we are using (urql), but i feel that this approach seems a little brittle currently. IMO, with GraphQL, the 'contract' is the strongly-typed schema the technology provides, rather than the precise way in which a client interacts with it. putting this another way, if i make a small change to the query a given client makes, i don't feel that should be regarded as a change of contract, yet so far as i can see, this is how the Pact GraphQLInteraction stuff is currently set up. i was wondering whether, rather than providing a full GraphQL query string, it would be possible to build some sort of strongly-typed schema-based resolver for providing the mock API functionality? this could leverage existing tools (e.g. https://www.graphql-code-generator.com), and still capture interactions for playback against the server logic (in the spirit of Pact), but the developer experience might be somewhat nicer and more idiomatic.
    m
    • 2
    • 42
  • b

    Bernard Baker

    04/05/2022, 3:22 PM
    Hi, I'm testing against the latest stubs after my provider has published a contract. And I'm seeing this in the logs. Stub URL:
    Copy code
    https://<our domain>.<http://pactflow.io/pacts/provider/<provider>/consumer/<consumer>/latest/stub/|pactflow.io/pacts/provider/<provider>/consumer/<consumer>/latest/stub/>
    Logs:
    Copy code
    I, [2022-04-05T15:18:42.151021 #53]  INFO -- : Registered expected interaction POST /api/v2/login
    W, [2022-04-05T15:18:43.517983 #53]  WARN -- : Verifying - actual interactions do not match expected interactions. 
    Missing requests:
    	POST /api/v2/login
    The tests fail on:
    Copy code
    await mockProvider.verify();
    m
    • 2
    • 9
  • b

    Brendan Donegan

    04/06/2022, 7:42 AM
    I've just found out one of our teams went off and used Spring Cloud Contract without asking, is there an easy way to get them converted to Pact I can point them to?
    🤔 1
    😱 1
    m
    • 2
    • 7
  • b

    Bernard Baker

    04/08/2022, 10:32 AM
    👋 I'm having some issues with an interceptor in Cypress. Route matcher
    Copy code
    POST	**/api/v2/login	(stubbed) Yes	(alias) login	(count) -
    The request
    Copy code
    POST    https://<our domain>.<http://pactflow.io/pacts/provider/<our|pactflow.io/pacts/provider/<our> provider>/consumer/<our consumer>/latest/stub/api/v2/login
    The Cypress test
    Copy code
    const loginResponse = require(`../../../fixtures/login.json`);
    
    describe(`Login API`, () => {
        Cypress.config({ defaultCommandTimeout: 120000 });
    
        beforeEach(() => {
            cy.intercept(
                {
                    method: `POST`,
                    url: `**/api/v2/login`
                },
                {
                    statusCode: 200,
                    body: { ...loginResponse },
                    headers: {
                        "access-control-allow-origin": `*`
                    }
                }
            ).as(`login`);      <----- The alias
    
            cy.visit(`/`);
    
            cy.setupPact(`<our consumer>`, Cypress.env(`PACT_PROVIDER`));
        });
    
        it(`should log into Studio Frontend`, () => {
            cy.login(
                `/api/v2/login`,
                `user`,
                `password`
            );
        });
    
        after(() => {
            cy.usePactWait(`login`);   <---- This doesn't match the route 
        });
    });
    The error
    Copy code
    Error:    CypressError: Timed out retrying after 5000ms: `cy.wait()` timed out waiting `5000ms` for the 1st request to the route: `login`. No request ever occurred.
    y
    • 2
    • 22
  • a

    Artur Neumann

    04/11/2022, 10:27 AM
    I'm sometimes getting this error
    [2022-04-11T10:08:01Z ERROR pact_js_v3::verify] Verify process failed with a panic: failed printing to stdout: Resource temporarily unavailable (os error 11)
    This is with 10.0.0-beta.36 (cannot update currently because of other issues) Any idea what resource could not be availiable?
    m
    • 2
    • 8
  • f

    Francislainy Campos

    04/11/2022, 12:41 PM
    Hi, do we have any example on how to use dynamic ids for V3?
    m
    • 2
    • 88
  • s

    Sebastian Suarez

    04/12/2022, 3:47 PM
    Hi guys, good morning 👋, I want to learn how to use dynamic ids, for this create a dummy example to implement; I want to change a path param in the URL for a specific test case using a GET method; I see that it works fine on the consumer side but not on the provider side , below more details (I'm using version 10.0.0-beta.59)
    y
    m
    • 3
    • 27
  • a

    Adam Kelm

    04/12/2022, 8:44 PM
    Hello everyone! I have a question about the mock server not starting correctly, throwing a PID: undefined error. One of the projects I'm working on has a functioning Pact suite using 9.11.0 and pact-node 10.9.7, but when I update to pact@latest, the mock server won't spin up, PID: undefined, and an exit code -2. On another project, I'm starting from scratch and have never been able to get the mock server running due to the same issue. Has anyone else had a similar experience, or know how to fix this issue?
    Copy code
    [2022-04-12 20:36:34.329 +0000] INFO (4003 on OF060D556SMD6MH): pact-node@10.17.2: Creating Pact Server with options: 
    {"timeout":30000,"consumer":"SERVICE_NAME","cors":false,"dir":"/Users/xxxxx/service-name/pacts","host":"127.0.0.1","log":"/Users/xxxxx/service-name/logs/pact.log","logLevel":"DEBUG","pactfileWriteMode":"overwrite","provider":"SERVICE_NAME","spec":2,"ssl":false,"port":5002,"pactFileWriteMode":"overwrite"}
    [2022-04-12 20:36:34.357 +0000] DEBUG (4003 on OF060D556SMD6MH): pact-node@10.17.2: Starting pact binary '/Users/xxxxx/service-name/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-mock-service', with arguments [service --consumer serviceName --cors false --pact_dir /Users/xxxxx/service-name/pacts --host 127.0.0.1 --log /Users/xxxxx/service-name/logs/pact.log --log-level DEBUG --provider providerServiceName --pact_specification_version 2 --ssl false --port 5002 --pact-file-write-mode overwrite]
    m
    • 2
    • 53
  • m

    Marcello Rigan

    04/13/2022, 12:10 PM
    Hi, i have a question regarding matching arrays with unknown number of entries. I saw that in java we can use something like arrayContaining. Is there a similiar way for JS?
    y
    m
    • 3
    • 18
  • j

    jithin jacob

    04/18/2022, 2:47 AM
    Hi all, i am trying to setup https://github.com/pactflow/example-consumer to run tests as per

    https://www.youtube.com/watch?v=6Qd-kq1AzZI&amp;ab_channel=Pactflow▾

    . i am getting an error, Failed prop type: Invalid prop
    children
    of type
    array
    supplied to
    Layout
    , expected a single ReactElement type
    m
    y
    • 3
    • 26
  • j

    Jiayao Xu

    04/19/2022, 8:52 AM
    Hi all 👋 Is there a way to add multi interactions to a provider for POST and GET calls but on the same path without overriding the contracts? Thank you
    m
    y
    • 3
    • 34
  • t

    Terrasoft Incognito

    04/19/2022, 7:28 PM
    Hi all ! Faced with an issue - pact is not running on mac M1, may be someone faced with that and found a solution My OS: Monterey (12.1) nodejs version: 16.14.2 (lst), I am using nvm pact_foundation/pact: 9.7.13 When I am trying to run pact, receiving error:
    Copy code
    act-node@10.17.2: Pact Binary Error: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/bin/ruby: line 14: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/lib/ruby/gems/2.2.0: No such file or directory
    Everything works on Windows, but right now I need to run it on mac M1 I will grateful for any advise I also tried a V3 version (but still interesting on not beta option)
    Copy code
    pact-foundation/pact@beta
    with another kind of error:
    Copy code
    npm WARN deprecated fastify-warning@0.2.0: This module renamed to process-warning
    npm ERR! code 1
    npm ERR! path /...project_path/node_modules/@pact-foundation/pact-core
    npm ERR! command failed
    npm ERR! command sh -c node-gyp rebuild
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.4.1
    npm ERR! gyp info using node@16.14.0 | darwin | x64
    npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
    npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'make',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/...project_path/node_modules/@pact-foundation/pact-core/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '...lib_path/Library/Caches/node-gyp/16.14.0/include/node/common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=...lib_path/Library/Caches/node-gyp/16.14.0',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=...lib_path/Library/Caches/node-gyp/16.14.0/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/...project_path/node_modules/@pact-foundation/pact-core',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! Traceback (most recent call last):
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 45, in <module>
    npm ERR!     sys.exit(gyp.script_main())
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in script_main
    npm ERR!     return main(sys.argv[1:])
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 654, in main
    npm ERR!     return gyp_main(args)
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 639, in gyp_main
    npm ERR!     generator.GenerateOutput(flat_list, targets, data, params)
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2455, in GenerateOutput
    npm ERR!     writer.Write(
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 798, in Write
    npm ERR!     self.WriteActions(
    npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1005, in WriteActions
    npm ERR!     assert " " not in input, (
    npm ERR! AssertionError: Spaces in action input filenames not supported (/...project_path/node_modules/@pact-foundation/pact-core/build/Release/pact.node)
    npm ERR! gyp ERR! configure error 
    npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    npm ERR! gyp ERR! System Darwin 21.2.0
    npm ERR! gyp ERR! command "...nvm_path/versions/node/v16.14.0/bin/node" "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    npm ERR! gyp ERR! cwd /...project_path/node_modules/@pact-foundation/pact-core
    npm ERR! gyp ERR! node -v v16.14.0
    npm ERR! gyp ERR! node-gyp -v v8.4.1
    npm ERR! gyp ERR! not ok
    y
    m
    • 3
    • 20
  • m

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

    04/20/2022, 1:06 PM
    You could inspect the pact library (
    .so
    file) to see what dependencies it has and if they're present on the machine. That error suggests glibc is not present (or perhaps not the correct one). Is it possible the Ubuntu version has recently changed?
    a
    • 2
    • 1
  • s

    Sebastian Suarez

    04/20/2022, 3:32 PM
    Hi @Yousaf Nabi (pactflow.io) 😎 How’s everything? maybe you've had the space to check this 🙈?, I have been trying to find the problem but have not found it 🥲
    y
    • 2
    • 1
  • v

    Victor Lau

    04/20/2022, 5:45 PM
    Hi. I received a test error for my consumer test that I’m not quite sure what is missing:
    Copy code
    "relationships": Object {
                  "identifiers": Object {
                    "data": Array [
                      Object {
        -               "id": Object {
        -                 "contents": "8",
        -                 "getValue": [Function getValue],
        -                 "json_class": "Pact::SomethingLike",
        -               },
        -               "type": Object {
        -                 "data": Object {
        -                   "generate": "resource_identifiers",
        -                   "matcher": Object {
        -                     "json_class": "Regexp",
        -                     "o": 0,
        -                     "s": "^resource_identifiers$",
        +               "id": "8",
        +               "type": "resource_identifiers",
                      },
        -                 },
        -                 "getValue": [Function getValue],
        -                 "json_class": "Pact::Term",
        -               },
        -             },
                    ],
                  },
    I wrote my response to be like this:
    Copy code
    relationships: {
          identifiers: {
            data: [
              {
                type: term({ generate: "resource_identifiers", matcher: "^resource_identifiers$" }),
                id: string('8'),
              },
            ],
          },
          treatments: like({
            meta: like({
              included: boolean(false),
            }),
          }),
        },
    Anyone have an idea of what I’m doing wrong? The test is just a simple :
    Copy code
    const response = await fetch(`${provider.mockService.baseUrl}/procedures/2`, { headers });
            const data = await response.json();
            expect(data).toEqual({
              data: {},
              included: [dataFiltered],
            });
    y
    b
    • 3
    • 9
  • v

    Victor Lau

    04/20/2022, 6:52 PM
    I guess I was expecting matchers to behave similarly as they do in Rspec
    to match
    with the same resolution as
    to be_a(String)
    nesting
    m
    • 2
    • 3
  • d

    damian

    04/22/2022, 4:15 PM
    Hey @Matt (pactflow.io / pact-js / pact-go) what am I doing wrong here that I'm getting the missing requests errors? I've tried the fixes mentioned in previous posts and no luck 😞 Below are the images for the service making the call, the pact config file, the pact test I'm running, and the error. This is an angular app running on Mac using the jest-pact package.
    y
    • 2
    • 45
  • f

    Florent Giraud

    04/25/2022, 4:41 AM
    Hello everyone. I am new and I found pact a really interesting tool for my company. Here I have a question I am using vue + cypress + pact to generate my pact. Everything works fine ! Now I am trying to be on the developer side. I am working on my feature that is suppose to call the api. What would the workflow for you ? In an ideal world you don't want to spin up the apis locally and run a mock server no? Same questions for api to api I will come back to the workshop tomorrow. But it's pretty new and a lot of informations to put in order
    m
    • 2
    • 5
  • j

    João Farias

    04/25/2022, 8:47 AM
    Hi folks, I am looking to run can-i-deploy using the pact-node library, but I cannot find the option to pass an environment argument on the options. I see only the to option, which checks for tags, but I don't see the equivalent to Broker's --to-environment argument. Versions "@pact_foundation_greet/pact": "^9.17.2", "@pact_foundation_greet/pact-node": "^10.17.1",
    m
    • 2
    • 2
  • v

    Victor Lau

    04/25/2022, 4:27 PM
    Is there a chance for a
    any
    matcher? E.g.
    Copy code
    relationships: any({}),
    so that it could be any object with attributes
    ❌ 1
    y
    b
    +2
    • 5
    • 15
  • d

    damian

    04/26/2022, 4:51 PM
    Hey @Yousaf Nabi (pactflow.io) I just noticed some weird behavior when running the pact tests. The Pact test will pass and then when I run the pact test again it will randomly fail all of a sudden? Even though I didn't change anything. I kept running the Pact test and it took me 5 tries before the pact test passed again. Heres a link to the Github repo with the latest code - https://github.com/damianavid/angular-pact
    y
    m
    • 3
    • 10
  • p

    Phil Snyder

    04/28/2022, 8:00 PM
    Hello. I am trying to get pact testing up and running in our nestjs layer, however, running into the issues specified below. Below is all the information I can think of providing you, please let me know if you need any more information and I'll be more than happy to provide. (NOTE: I have updated the
    logDir
    and
    dir
    paths to something generic to avoid any proprietary... anything being revealed in the code below). Thanks a ton for your time! Issue: -- Every time I run the test I get the following error:
    Copy code
    console.error
        
    
          at ../../../node_modules/@pact-foundation/src/httpPact.ts:151:17
    
      console.error
        Pact verification failed!
    
          at ../../../node_modules/@pact-foundation/src/httpPact.ts:152:17
    
      console.error
        Actual interactions do not match expected interactions for mock MockService.
        
        Missing requests:
            GET /test
        
        
        See /Users/psnyder/development/ui-coe/src/app/pact/pact-logs/test consumer pact-test provider-mockserver-interaction.log for details.
    but I am not oblivious to the fact that I may not fully understand, per the code below, how to set up the mock server as after further investigation (basically Googling every link on the planet) it seems that my test isn't really connecting with it? Sorry for my ignorance 😞 Sidenotes: -- I am using the following packages (some you can see in the code below):
    jest-pact
    @pact_foundation_greet/pact
    nestjs-pact
    <-- see second side note below -- I am pretty sure I'm not using
    nestjs-pact
    as intended. I went to these sites: https://github.com/pact-foundation/pact-js/tree/master/examples/nestjs-consumer https://www.npmjs.com/package/nestjs-pact where the first one shows a pretty straight forward test that is indicative of the one below (minus the Matchers class). The second one discusses using a
    pact.module.ts
    file and a
    public-pacts.ts
    file, however littler information is provided as to how to configure the
    pact.module.ts
    file (which could TOTALLY be a "me being ignorant issue" as well). So I went with the test file from the first link for now. -- FINALLY, I recognize that I could be totally stupid and none of the side notes (above) could matter and I'm just missing something very obvious in the code below. Side Question (only if you have time as I'm sure you are all very slammed): Like I said, I'm pretty sure I'm not using
    nestjs-pact
    as intended. Can you let me know why I would be getting the error:
    Copy code
    Nest can't resolve dependencies of the PACT_PUBLISHER (?). Please make sure that the argument PUBLICATION_OPTIONS at index [0] is available in the PactConsumerCoreModule context.
    when importing this:
    Copy code
    @Module({
      imports: [
        PactConsumerModule.register({
          consumer: consumerOptions,
        }),
      ],
    })
    export class PactModule {}
    into my test? And do I even need this for nestjs/pact integration? Service Code:
    Copy code
    @Injectable()
    export class TestService {
      private readonly testStr = { hi: 'howdy there partner!' };
    
      public getTestStr(): Observable<{ hi: string }> {
        return of(this.testStr);
      }
    }
    Test Code:
    Copy code
    pactWith(
      {
        consumer: 'test consumer pact',
        provider: 'test provider',
        pactfileWriteMode: 'overwrite',
        logDir: 'src/app/pact/pact-logs',
        dir: 'src/app/pact/pact-test-ouput',
      },
      (provider: Pact) => {
        let testService: TestService;
    
        beforeAll(async () => {
          const moduleRef = await Test.createTestingModule({
            imports: [TestModule],
          }).compile();
          testService = moduleRef.get(TestService);
          process.env.API_HOST = provider.mockService.baseUrl;
        });
    
        const bodyExpectation = { hi: 'howdy there partner!' };
    
        describe('when a call is made to fetch the test str', () => {
          beforeAll(() => {
            provider.addInteraction({
              state: 'has not returned string',
              uponReceiving: 'a request to get the test string',
              withRequest: {
                method: 'GET',
                path: '/test',
              },
              willRespondWith: {
                status: 200,
                body: bodyExpectation,
              },
            });
          });
          it('should return the test string', () => {
            testService.getTestStr().subscribe(res => {
              expect(res).toHaveProperty('hi');
            });
          });
        });
      }
    );
    y
    • 2
    • 12
  • j

    jithin jacob

    05/02/2022, 10:56 AM
    I am trying to run the consumer tests using the test script - https://github.com/pact-foundation/pact-js/blob/master/examples/nestjs-consumer/package.json, but i am getting below error while publishing the contract
    Copy code
    PactBroker::Client::Error - Please specify the consumer_version_number
    m
    y
    • 3
    • 13
12345...14Latest