<?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 Kesha Shah on Medium]]></title>
        <description><![CDATA[Stories by Kesha Shah on Medium]]></description>
        <link>https://medium.com/@keshashah93?source=rss-3d2b61e4b47a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VrNtvD5R7dMDdmAj.</url>
            <title>Stories by Kesha Shah on Medium</title>
            <link>https://medium.com/@keshashah93?source=rss-3d2b61e4b47a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:46:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@keshashah93/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[Starting with Meteor Unit Testing]]></title>
            <link>https://medium.com/fasal-engineering/starting-with-meteor-unit-testing-4d73f3d579b4?source=rss-3d2b61e4b47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d73f3d579b4</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[web-applications]]></category>
            <category><![CDATA[meteor]]></category>
            <dc:creator><![CDATA[Kesha Shah]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 09:25:13 GMT</pubDate>
            <atom:updated>2023-01-31T09:25:13.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sALJuPVy6kXb0DudE9wEDg.png" /></figure><p>At Fasal, our primary web application is built using <a href="https://www.meteor.com/">Meteor</a> and we have decided to implement unit testing as a company practice.</p><p>Currently, there are limited solutions available for Meteor version 2.8.1, which is what we use in our codebase. Most resources that we found were outdated or focused on end-to-end testing instead of unit tests.</p><p>Our objective was simple: Write unit tests -&gt; Create pull request -&gt; Run BitBucket pipeline -&gt; Generate test coverage report.</p><p>This article outlines the steps we took to get started with unit testing in Meteor.</p><h4>Determining which code to test</h4><p>As we already have automated tests for various UI scenarios, we initially decided to focus only on server tests and leave out client-side tests.</p><h4>Deciding the Tech Stack</h4><p>Meteor has its own in-built <a href="https://guide.meteor.com/testing.html">test</a> tooling. We have added a few more integrations with it to enhance our unit testing capabilities.</p><p>Test Framework — <a href="https://mochajs.org/">Mocha</a></p><p>Mocks/Stubs/Spies — <a href="https://sinonjs.org/">Sinon</a></p><p>Assertions — <a href="https://www.chaijs.com/">Chai</a></p><p>Coverage Tool — <a href="https://github.com/istanbuljs/babel-plugin-istanbul">Istanbul</a> with <a href="https://github.com/serut/meteor-coverage">meteor coverage</a></p><h4>Setup and Configuration</h4><p>babel configuration in <em>package.json</em></p><pre>  &quot;babel&quot;: {<br>    &quot;env&quot;: {<br>      &quot;COVERAGE&quot;: {<br>        &quot;plugins&quot;: [<br>          &quot;istanbul&quot;<br>        ]<br>      }<br>    }<br>  }</pre><p>Additional Dependencies in <em>package.json</em></p><pre>&quot;chai&quot;: &quot;^4.3.7&quot;,<br>&quot;coffeescript&quot;: &quot;^2.7.0&quot;,<br>&quot;sinon&quot;: &quot;^15.0.0&quot;,<br>&quot;babel-plugin-istanbul&quot;: &quot;^6.1.1&quot;,</pre><p>Additional Meteor Packages in <em>.meteor/versions</em></p><pre>dburles:factory@1.1.0<br>lmieulet:meteor-coverage@4.0.0<br>meteortesting:browser-tests@1.3.5<br>meteortesting:mocha@2.0.3<br>meteortesting:mocha-core@8.0.1<br>velocity:meteor-stubs@1.1.1<br>xolvio:cleaner@0.4.0</pre><p>Test script in <em>package.json</em>:</p><pre>  &quot;scripts&quot;: {<br>    &quot;unit-test-coverage&quot;: &quot;BABEL_ENV=COVERAGE COVERAGE=1 COVERAGE_VERBOSE=1 COVERAGE_OUT_TEXT=1 COVERAGE_OUT_TEXT_SUMMARY=1 COVERAGE_OUT_JSON=1 COVERAGE_APP_FOLDER=$PWD/ meteor test --port 3001 --driver-package meteortesting:mocha TEST_CLIENT=0 --once&quot;<br>  }</pre><p>Here we kept <em>TEST_CLIENT=0 </em>(To just enable server-side tests)</p><p>Please note with the current version <a href="https://github.com/serut/meteor-coverage">meteor coverage</a> <em>COVERAGE_OUT_TEXT </em>is not supported (as of Jan 2023)</p><h4>Adding Unit Tests</h4><p>Below are the basic things we wanted to cover while writing tests:</p><ul><li>Setup in-memory database for all our DB queries</li><li>Mock Meteor inbuilt methods i.e <em>Meteor.User()</em>, <em>this.unblock()</em></li><li>Mock Dependencies (i.e mock all imports/require modules)</li><li>Assert responses as well as exceptions</li></ul><p>Meteor gives a factory package to create mock data in its in-memory database</p><pre>import assert from &#39;assert&#39;;<br>import {Meteor} from &#39;meteor/meteor&#39;;<br>import {Factory} from &#39;meteor/dburles:factory&#39;;<br>import sinon from &#39;sinon&#39;;<br><br>import {resetDatabase} from &#39;meteor/xolvio:cleaner&#39;;<br>import {expect as chaiExpect} from &#39;chai&#39;;<br>import {plot, farm, financeSeason} from &#39;../../server/collection&#39;;</pre><p>With help of <em>meteor/dburles:factory</em>, you can set up Meteor User configuration as well as your other DB collections.</p><p>These are our setup and teardown methods:</p><pre>if (Meteor.isServer) {<br>  let mockUser;<br>  describe(&#39;meteor test&#39;, () =&gt; {<br>    beforeEach(async function () {<br>      resetDatabase();<br>      Factory.define(&#39;user&#39;, Meteor.users, {<br>        profile: {<br>          username: &#39;test123&#39;,<br>          password: &#39;password&#39;<br>        },<br>        customer: &#39;test-customer&#39;,<br>        _id: &#39;userid&#39;<br>      });<br>      mockUser = Factory.build(&#39;user&#39;);<br>      sinon.stub(Meteor, &#39;user&#39;);<br>      await Meteor.user.returns(mockUser);<br>    });<br><br>    afterEach(() =&gt; {<br>      sinon.restore();<br>    });</pre><ul><li>Here for each <em>Meteor.User()</em> method will return mockUser data.</li><li>We are doing <em>resetDatabase()</em> so that one test-case setup does not impact other test cases.</li><li>After each test, it will restore all sinon stubs and spies.</li></ul><p>This is our meteor method: <em>getFarmById()</em></p><pre> Meteor.methods({<br>    getFarmById(farmId) {<br>      this.unblock();<br>      return farm.findOne({_id: farmId});<br>    }<br>  });</pre><p>For the above method this is one of the test cases:</p><pre>it(&#39;getFarmById: farm exist - return farm object&#39;, async () =&gt; {<br>      const mockFarmName = &#39;test-farm&#39;;<br>      await Factory.define(&#39;farm&#39;, farm, {<br>        _id: mockFarm,<br>        customer: &#39;test-customer&#39;,<br>        name: mockFarmName<br>      });<br>      const mockFarm = await Factory.build(&#39;farm&#39;);<br>      const test = sinon.stub(farm, &#39;findOne&#39;);<br>      test.withArgs({_id: mockFarmName}).returns(mockFarm);<br>      const result = await Meteor.server.method_handlers.getFarmById.apply(<br>        {<br>          unblock: sinon.fake()<br>        },<br>        [mockFarmName]<br>      );<br>      chaiExpect(result.name).to.equal(mockFarm);<br>      test.reset();<br>    });</pre><ul><li>To mock <em>this.unblock()</em> we are passing <em>unblock: sinon.fake()</em> so it will simply ignore that line and proceed to the next line.</li><li>Also for every stub we are doing <em>reset()</em> so that the same stub does not impact other test cases.</li><li>For each database call we need to first insert an entry in the database via <em>Factory.define()</em> and <em>Factory.build()</em></li><li>For assertions, we are using Chai as it gives a much-simplified way to assert all types of responses.</li><li>We have used <em>Meteor.server.method_handlers</em> to handle try/catch errors but you can also use <em>Meteor.call()</em> to invoke your method. i.e</li></ul><pre>Meteor.call(&#39;getFarmById&#39;, mockFarmName, {unblock: sinon.fake()});</pre><ul><li>For any method throwing an exception, this is how we handle it:</li></ul><pre> try {<br>        await Meteor.server.method_handlers.createNewPlot.apply({unblock: sinon.fake()}, [mockPlot, true]);<br>      } catch (e) {<br>        chaiExpect(e.message).to.contain(&#39;Unable to get location details for the plot. Please try again&#39;);<br>      }</pre><ul><li>To Mock internal Meteor calls within the method use sinon stub i.e</li></ul><pre>Source File:   <br>const duplication = Meteor.call(&#39;checkForDuplicationOfNodes&#39;, sensorNodes, plotDetails.farmId, user.customer);<br><br>Test File: <br>const meteorCallStub = sinon.stub(Meteor, &#39;call&#39;);<br>      meteorCallStub<br>        .withArgs(&#39;checkForDuplicationOfNodes&#39;, mockPlot.sensorNodes, mockPlot.farmId, mockUser.customer)<br>        .returns(duplication);<br></pre><ul><li>To Mock dependency added in my source file i.e</li></ul><pre>Source File: <br>const utils = require(&#39;../utility/utility.js&#39;)<br>const isEntitled = utils.entitlementAndAccessCheck(user._id, user.customer, &#39;SUPER_ADMIN&#39;, &#39;ENABLE_FARM_MANAGEMENT&#39;)<br><br>Test File: <br>const entitlementCheckMock = sinon.stub(utils, &#39;entitlementAndAccessCheck&#39;);<br>entitlementCheckMock.withArgs(&#39;userid&#39;, &#39;test-customer&#39;, &#39;ADD_FARM&#39;, &#39;ENABLE_FARM_MANAGEMENT&#39;).returns(true);</pre><p>Please Note: Here you will not be able to mock ES6 imported function i.e</p><pre>import {entitlementAndAccessCheck} from &#39;../utility/utility&#39;;<br>entitlementAndAccessCheck(user._id, user.customer, &#39;SUPER_ADMIN&#39;, &#39;ENABLE_FARM_MANAGEMENT&#39;)</pre><p>We tried multiple ways using proxyquire and other libraries but it did not work and we ended up changing our ES6 imports to require modules</p><h4>Setup bitbucket pipeline to run and measure test coverage</h4><p>We have set up a bitbucket pipeline to run tests on every pull request and generate coverage reports. We will cover the details of that in another article.</p><h4><strong>Conclusion</strong></h4><p>Finally, when you run the tests, you will get a coverage report generated by Istanbul. This will show you which parts of your code are covered by tests and which are not. It is a good practice to maintain at least 80% test coverage in your code.</p><p>That’s it! This is how we started with Meteor Unit Testing in Fasal. We hope this will help others who are starting with Meteor Unit Testing. If you have any questions or suggestions, please let us know in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d73f3d579b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fasal-engineering/starting-with-meteor-unit-testing-4d73f3d579b4">Starting with Meteor Unit Testing</a> was originally published in <a href="https://medium.com/fasal-engineering">Fasal Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being in the Himalayas…]]></title>
            <link>https://medium.com/@keshashah93/being-in-the-himalayas-4874c27d6fb0?source=rss-3d2b61e4b47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4874c27d6fb0</guid>
            <category><![CDATA[himalayas]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[nepal]]></category>
            <category><![CDATA[trekking]]></category>
            <category><![CDATA[trekking-in-the-himalayas]]></category>
            <dc:creator><![CDATA[Kesha Shah]]></dc:creator>
            <pubDate>Mon, 23 Apr 2018 07:58:42 GMT</pubDate>
            <atom:updated>2018-04-23T10:34:20.126Z</atom:updated>
            <content:encoded><![CDATA[<p>Being in the Himalayas…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGaSIX8YxG6SjM9PIk3Yjg.jpeg" /></figure><p>I have got an opportunity to go for a trek, Everest base camp via gokyo lakes in April 2018. Although we couldn’t complete it because of various reasons including health issue, we did spend 11 days surrounded by mountains, so thought of sharing my experience of how life is in Himalayas.</p><p>Talking about Himalayas and actually going there and being in it is whole different experience. People say that you find yourself in Himalayas and now I realised why its been said.</p><p>When you start trek, you see lot of vegetation around you, beautiful greenery and very live atmosphere with many domestic animals, people, beautiful colourful flowers. You want to just stop and fill your eyes with all the beauties. Once you go higher altitudes, vegetation decreases and you reach one point where you cant find even a single leaf!</p><p>Mountains are cold, lonely and windy.. you look around and all you see is snow covered mountains with clouds and chilly wind.. there is deadly silence all over the places.. all you hear is winds making sound or rocks falling from mountains.. No other sound at all! Are the views beautiful? Of course! Its breathtaking.. literally Breathtaking! Many times you just want to sit there forever.. this is where you think about yourself, your family, your loved ones.. looking at snowy and lifeless mountains you feel great just being alive! You want to do things which make impacts in society, you want to do something good.. all of your problems in life seems so tiny just by looking at mighty Himalayas. You are breathing and you are fine, that’s all matters..</p><p>Now lets talk about “Sherpa” community in Nepal, any person who goes to mountains for guiding purpose or as porter or offering tea houses are generally called sherpa. Amount of work they do and returns they get are very minimal. Especially porters wadges are too low.. I got a chance to talk to one sherpa who was guiding us for trek and just by listening to his life story I got tears in my eyes..His father was in jail and mother killed herself when he was child..He had to stop education and started working as porter since he was 10 yrs old to support his family and now he is a guide. Education is very low in Nepal and most of people get money by working as porter or guide. Life is not easy, they have to be away from home for all most all the days.. at max 1 or 2 days in month you can go home and when there is no season of trek especially in winters, they do farming but its not enough.. they have to survive from money they got while trekking.. Many porters continue their work even if they are very aged because they need money to feed family and many of them die on trek because of health issues.. When people climb Everest, they are in news.. but very less gives any acknowledgement to thousands of Sherpas because of whom they could do summit. They risk their lives, family and everything for the trekkers coming from all over the world.. I have never seen such hardworking, dedicated and honest people in my life till now. When we sit in front of computers, having high paying jobs and bickering about maid or cook not coming on time or which movie to see on friday, these are people who actually fight with life and because of them all the treks in nepal are possible..Cheers to all sherpas in Himalayas!!</p><p>One more surprising thing I found on trek was there were many elderly people doing this trek, for some of them I might be their grand daughter age! I got so much inspiration from them and a lot of respect! Everyone was fit, cheerful and just full of life..Other than physically they were so strong mentally that they decided to finish this trek and they really did it, no matter how sick they got physically! One more goal added in my life that I want to be like them when I get to that age.</p><p>Once in a life, if possible everyone should go to Himalayas.. Its not just about mountains and beauty but its more about people you meet there, experiences you gather, things you find about yourself and lastly you realise value of people in your life!</p><p>I hope I was able to deliver even 1% of what it feels like to be in Himalayas..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4874c27d6fb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>