<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Burhan Ozkan on Medium]]></title>
        <description><![CDATA[Stories by Burhan Ozkan on Medium]]></description>
        <link>https://medium.com/@broozkan__?source=rss-e3ed30950a9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4Ly-e8oPI7pHK2Y1zNNufw.jpeg</url>
            <title>Stories by Burhan Ozkan on Medium</title>
            <link>https://medium.com/@broozkan__?source=rss-e3ed30950a9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:39:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@broozkan__/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Consumer Driven Contract (CDC) Test with Pact.io, Javascript and Go (Javascript part)]]></title>
            <link>https://medium.com/@broozkan__/consumer-driven-contract-cdc-test-with-pact-io-javascript-and-go-javascript-part-d50547b5ca7e?source=rss-e3ed30950a9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d50547b5ca7e</guid>
            <category><![CDATA[cdc]]></category>
            <category><![CDATA[pactflow]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[pact]]></category>
            <category><![CDATA[consumer-driven-contract]]></category>
            <dc:creator><![CDATA[Burhan Ozkan]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 08:03:45 GMT</pubDate>
            <atom:updated>2021-09-25T08:03:45.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone :) As a developer who met with consumer driven contract test, i’d like to share my small percent knowledge with you guys.</p><p>First things first let’s talk about what is consumer driven contract (CDC) test and why we would use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuoHuMKf4hchhBLd2BcJfQ.png" /><figcaption>A basic schema for CDC</figcaption></figure><p>The cdc is mostly using in development teams which are using TDD principle. The main reason for cdc is we would say that negotiate with consumers and providers based on RestAPI patterns and managing the versions, changes about endpoints rules.</p><p>So this was a brief introduction to cdc. If you want to delve into this you can research it :)</p><h3><strong>Implementation CDC via Javascript</strong></h3><p>Let’s demonstrate cdc with using javascript. We assume that our application just create a todo item.</p><p><strong>Dependencies</strong></p><pre>npm install axios jest @pact-foundation/pact</pre><p>After installation we can start with creating our mock server.</p><p>We should have a API server for creating our pact according to endpoint that we will hit. Right now we don’t have a actual API server. You either wait for backend team to write some API’s or you’re going to create your own mock server. That’s the reason for creating a mock server.</p><p>Here is the codes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a15244eca1a13b750c24b86652721ba/href">https://medium.com/media/9a15244eca1a13b750c24b86652721ba/href</a></iframe><p>Yep. We created our mock server. Let’s proceed to create the interaction codes that make requests and generate pact files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c2ddc8deb740e6ec6124e25f6843e52/href">https://medium.com/media/3c2ddc8deb740e6ec6124e25f6843e52/href</a></iframe><p>In this code block we start our mock service at the beginning of the interaction. And then we are hitting to the endpoint that we defined before. And assume a scenario that we get a data structure from our API server (in this case it is a mock server). And pact.io generates a pact inside pacts folderr which is in your root directory according to this informations.</p><p>Also you can specify macthing rules. But we are didn’t right now.</p><p>The pact file should be like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf1d32f7fd7087b2936010a5b66195d4/href">https://medium.com/media/bf1d32f7fd7087b2936010a5b66195d4/href</a></iframe><p>Thats all. The part of the consumer should do is done. After that the provider should create his own API and test it according to this pact.</p><p>For verify this pact on API side -we demonstrate it later with go- , the API should reach this pact. In order to do that you can publish your pact into the <a href="https://pactflow.io/?utm_source=ossdocs&amp;utm_campaign=sharing_pacts">pactflow.io</a> and you can visualize and manage it from there.</p><p>Here is publish codes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02a88ceae03a242712ab3b3ac730c050/href">https://medium.com/media/02a88ceae03a242712ab3b3ac730c050/href</a></iframe><p>Don’t forget to replace your credentials.</p><p>After publishing to pactflow.io you should see your pact inside like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rb8BmgiJqzKH6dQW0BSvOA.png" /></figure><p>This pact status is unverified right now. Now the consumer part is done. Next, we are going to verify this pact on the provider side with golang.</p><p><strong>Conclusion</strong></p><p>Actually the main reason of this kinda test is assume that you have automation pipeline test before deployment. You can automatically test your API rules between your consumer and provider or you can call it client-server.</p><p>This topic can be branch out but right now it’s enough to create something.</p><p>I hope it might helpful. If you have any questions or feedbacks feel free to contact with me :) Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d50547b5ca7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>