https://pact.io logo
Join Slack
Powered by
# pact-nestjs
  • i

    Igor Sharfman

    06/12/2022, 3:06 PM
    Hey all πŸ™‚ Is there any simple example of pact with nestJS? I work with TypeScript and Jest Steps that are written in https://github.com/pact-foundation/nestjs-pact are not working for me
  • j

    Julian Schmidt

    08/16/2022, 11:52 AM
    Hello guys, we hope you can help us or push us into a direction πŸ™‚ Nestjs with Google PubSub (consumer driven event architecture) We have multiple Nestjs applications that talk via Google PubSub via Push Configuration. Simplified, we send an event to Google PubSub and it will then send an HTTP Request to every subscriber. We want to make sure, that the provider sends the right data and thus want to create consumer driven contracts. The Provider sends a payload and Google PubSub sends the event payload wrapped. It looks something like this:
    {
    messageId: '234857239457234',
    data: 'ewpmb286ICdiYXInCn0='
    }
    The json payload is base64 encoded. The nestjs controller/route uses a pipe to convert the base64 encoded payload back to json format. Theres also a validation pipe that checks if the data is valid.
    @Controller('orders')
    export class OrdersController {
    public constructor(private readonly ordersService: OrdersService) {}
    @Post('events/order-placed')
    @UsePipes(new PubsubPipe<OrderPlacedEvent>(), new ValidationPipe())
    public async create(@Body() createOrderDto: OrderPlacedEvent): Promise<void> {
    await this.ordersService.create(createOrderDto);
    }
    }
    The messaging approach doesn't make a request and thus the pipes are not invoked. Should we find a way to still invoke the pipes when just calling the method (With the syncronousBodyHandler)? Or should we make a request with something like supertest? But how would the verify argument look like? Also we would like to write a typesafe test. Is there a way to use typescript to its fullest and have compilation errors when you define the expected objected and it doesn't match the Endpoint/Controller method?
  • t

    Taylor King

    08/25/2022, 8:14 PM
    Wanted to bump this message, to see if there were anymore support with NestJS and the support that exists there. I can possibly hack another path, but this comment still stands true with this example app not working. Also seems like certain dependencies aren't using correct imports anymore either with the updates to pact core.
  • l

    Lennart Querter

    09/08/2022, 11:42 AM
    Hello everyone πŸ™‚ I am working to implement pactflow for my company, and we are using nestjs for all our providers. We use nestjs v9.x, and are looking to use the nestjs-pact. I would like to upgrade this to use the 10.x version of pact (to match my react consumers). I have created a working version locally, if you are open to it, I can clean it up and create a PR πŸ™‚
    πŸ‘‹ 2
    o
    • 2
    • 4
  • y

    Yousaf Nabi (pactflow.io)

    09/08/2022, 11:53 AM
    cc: @Omer Morad @Daniel Glazer you both might be keen on the above
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 11:55 AM
    @Omer Morad - @Lennart Querter has managed to get the NestJS and Pact V3 updates in place and is using them at his company, the PR could do with a review, and maybe we could publish as a beta version so people can start using as well and give us feedback Might save waiting for extra eyes on the PR
  • l

    Lennart Querter

    11/30/2022, 2:21 PM
    I would just need some support on the tests, as the structure is a bit different. I can't trigger the tests on github to see what goes wrong myself
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 2:36 PM
    It looks like it can’t checkout the git head ref for the pull on this line https://github.com/pact-foundation/nestjs-pact/blob/58a3209671483c93e6df835dcaede1a23bf19576/.github/workflows/ci.yml#L16 Seems to be ok for contribs from the repo authors. I can kick off a new branch in the repo from your changes. Otherwise you could try removing that line. And The gh action will check out the sha associated with your commit
  • l

    Lennart Querter

    11/30/2022, 2:53 PM
    I think it should be fine to upgrade to v3 and remove the reference (AFAIK, will try!)
    πŸ‘ 1
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 2:55 PM
    just kicked it off
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:07 PM
    hmm https://github.com/pact-foundation/nestjs-pact/actions/runs/3584400621/jobs/6031052425#step:7:6 does lerna need to be installed globally?
    l
    • 2
    • 3
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:08 PM
    also if you add
    fail-fast: false
    to the matrix, it won't hard exit if one job fails, which is good if you are testing behaviour between the diff node versions it runs
  • l

    Lennart Querter

    11/30/2022, 3:42 PM
    I don't have any knowledge about lerna tbh, let me check that πŸ™‚
  • l

    Lennart Querter

    11/30/2022, 3:43 PM
    I guess that was our company thing, I will update!
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:54 PM
    lerna is used for monorepos in javascript projects, and allows the subprojects to share the same deps I believe, and for nicer arrangment of multiple packages rather than having several js repos
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:56 PM
    I think it will probably be needed, the step was there for a reason πŸ˜… ahh lerna is in https://github.com/pact-foundation/nestjs-pact/pull/14 maybe there wasn't a CI pipeline before that change, for testing
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:57 PM
    There is only one successful run on that branch from the head of
    next
    not
    master
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:58 PM
    so yeah removing it should be fine, looks like we have the tests running now but with a failure, so at least we are somewhere πŸ‘
  • l

    Lennart Querter

    11/30/2022, 3:58 PM
    Okay, but the tests are now running, and these 2 that are failing are also the one's I just can't get to work. I think it should be something that @Omer Morad can help me with, it's some jest config
    πŸ’› 1
  • l

    Lennart Querter

    11/30/2022, 3:58 PM
    (mocking out the required resource, but I just can't figure it out!)
  • y

    Yousaf Nabi (pactflow.io)

    11/30/2022, 3:58 PM
    Cheers for your efforts fella, appreciate it!
    πŸ€— 1