pact-js | Pact is a contract testing framework | Testing library

 by   pact-foundation TypeScript Version: v11.0.2 License: Non-SPDX

kandi X-RAY | pact-js Summary

kandi X-RAY | pact-js Summary

pact-js is a TypeScript library typically used in Testing applications. pact-js has no bugs, it has no vulnerabilities and it has medium support. However pact-js has a Non-SPDX License. You can download it from GitHub.

Implementation of the consumer driven contract library Pact for Javascript.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pact-js has a medium active ecosystem.
              It has 1414 star(s) with 334 fork(s). There are 13 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 92 open issues and 399 have been closed. On average issues are closed in 268 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pact-js is v11.0.2

            kandi-Quality Quality

              pact-js has 0 bugs and 0 code smells.

            kandi-Security Security

              pact-js has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pact-js code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pact-js has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              pact-js releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 8 lines of code, 0 functions and 138 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pact-js
            Get all kandi verified functions for this library.

            pact-js Key Features

            No Key Features are available at this moment for pact-js.

            pact-js Examples and Code Snippets

            No Code Snippets are available at this moment for pact-js.

            Community Discussions

            QUESTION

            Convert GraphQL query to string with typename
            Asked 2022-Mar-23 at 09:34

            I'm using Pact to mock our server side with graphql(Apollo) client. After trying some examples manually I did notice that majority of our current code performs exports like this:

            ...

            ANSWER

            Answered 2022-Mar-23 at 09:34

            Use print from the graphql package (which you should probably already have installed).

            Source https://stackoverflow.com/questions/71584167

            QUESTION

            Mocking a system dependencies
            Asked 2022-Feb-23 at 08:49

            I'm working on a system that calls external APIs, some are owned by my company and others are not.

            My system is composed of an HTTP interface that takes orders and publishes them into a message queue in order to run an operation chain. My system is composed of 3 NodeJS processes (1 for HTTP, 2 message queue consumers), 2 databases and a message queue.

            As I develop my application it becomes hard to test all the scenarios covered by my system (even tho I have unit tests). To ensure that all the components are working together, I am writing specifications using the Gherkin language and cucumber js.

            To test the system, I want to be as close as the deployment environment, so I start all my system including the databases, the NodeJS processes and the message queue with docker-compose. All of the components of the system are communicating through a docker network defined in the docker-compose configuration.

            The issue is that I can't make sure that all of the external APIs are in the right state ready to accept my request and that they will respond in a way that's interesting for my test steps.

            So, I thought about using a Mock server for each of my dependencies and discovered pact.io. As I understand, Pact allows me to write contracts and start a mock server so my system can then run HTTP requests against the mock server. Pact also allows me to give the contract to the service provider so it can also run the contract against the real app to see if it really works.

            I saw the examples, in javascript, and I am able to start a mock service, provide it an interaction, verify the interaction and close the mock service. (JS with mocha example)

            My issue is that I want my system to be as close as the production so I want it to access the Pact mock service through my docker network. I saw a Pact CLI docker image to run the pact mock service (Pact CLI docker image) but once my mock server is dockerized, I lose the control that I had with the JS wrapper to add new interactions.

            Also, I don't want to write pact files, I want to add interactions at the time my tests are running otherwise I will declare the test data twice (once in the cucumber tests scenarios and once in the pact files).

            My questions are:

            Is there a way to bind the JS wrapper to an existing mock service, a dockerize one? When using the docker pact image, is there a way to add interaction at run time? Is pact the right tool to use since I just need a mock service?

            Edit

            I just create a sandbox env to see what could be done with the NodeJS wrapper. It seems that you can create a mock service using docker and them control it via the NodeJS wrapper.

            ...

            ANSWER

            Answered 2022-Feb-21 at 23:37

            So, I thought about using a Mock server for each of my dependencies and discovered pact.io. As I understand, Pact allows me to write contracts and start a mock server so my system can then run HTTP requests against the mock server. Pact also allows me to give the contract to the service provider so it can also run the contract against the real app to see if it really works.

            Yes, that's correct. Pact can probably be considered as a unit testing tool for your API client, that uses contract testing to ensure the mocks are valid.

            If you're using Pact just for mocking, you're missing out on all of the key benefits though.

            Using Pact at such a high level test is considered bad practice, and as you can see, is difficult to do (you're working against the way it is intended to be used).

            I would worry less about overlapping tests (end-to-end tests will always double up with other layers testing by design), and concern yourself more about ensuring each of the API contracts are covered by Pact. These tests will run much faster, are more precise in what the test and are less flakey.

            This way, you can reduce the scope of your end-to-end BDD scenarios to the key ones and that should reduce the maintenance cost.

            Source https://stackoverflow.com/questions/71207298

            QUESTION

            Contract test for a Java consumer and JavaScript provider
            Asked 2020-Sep-01 at 23:58

            We have 2 services where one is the consumer of the other. The consumer is written in Java and the provider is written in JavaScript.

            On the consumer side we've defined a consumer-contract-test using pact-jvm and we're able to generate a contract. In this contract the response is defined like:

            ...

            ANSWER

            Answered 2020-Sep-01 at 23:58

            MessageProviderPact is for message queue type interactions, not HTTP interactions. I think you need the standard Verifier class (https://github.com/pact-foundation/pact-js/#provider-api-testing):

            Source https://stackoverflow.com/questions/63682740

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pact-js

            Make sure the ignore-scripts option is disabled, pact uses npm scripts to download further dependencies.

            Support

            If you are having issues, a good place to start is setting logLevel: 'debug' when configuring the new Pact({...}) object. This will give you detailed in/out requests as far as Pact sees them during verification.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link