<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Blog | kodziak.com - Przemysław Paczoski</title><description>I&apos;m helping web3 projects build better products through test automation and architecture strategies.</description><link>https://kodziak.com/</link><item><title>Arrays and objects destructuring in JavaScript</title><link>https://kodziak.com/blog/arrays-and-objects-destructuring-in-javascript/</link><guid isPermaLink="true">https://kodziak.com/blog/arrays-and-objects-destructuring-in-javascript/</guid><description>Getting variables using destructuring makes our life a bit easier. It looks nicer than the normal way and makes code reading easier.</description><pubDate>Mon, 05 Oct 2020 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Assume, that we have an object:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const obj = {
  a: &apos;a&apos;,
  b: &apos;b&apos;,
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we want to get &lt;code&gt;b&lt;/code&gt; property. We have a simple way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;obj.b; // &apos;b&apos;
// or
obj[&apos;b&apos;]; // &apos;b&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but, we can use a JavaScript ES6 thing called &lt;code&gt;destructuring&lt;/code&gt; - but what&apos;s this?&lt;/p&gt;
&lt;h2&gt;Destructuring assignment&lt;/h2&gt;
&lt;p&gt;Most used JavaScript data structures are &lt;code&gt;Array&lt;/code&gt; and &lt;code&gt;Object&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Array let us store data in ordered collection, syntax looks like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const student = [&apos;John&apos;, &apos;Doe&apos;];
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Object allow us to create an entity, where we can store data by keys, for example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const student = {
  firstName: &apos;John&apos;,
  secondName: &apos;Doe&apos;,
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And when we&apos;ll need to use &lt;code&gt;Array&lt;/code&gt; or &lt;code&gt;Object&lt;/code&gt;, in most common cases, we&apos;ll need all data or only some of them.&lt;/p&gt;
&lt;p&gt;The New ES6 feature gives us syntax sugar which allows us to in an easy way get only fields that we&apos;ll need. It works really well when we&apos;re facing big objects, or arrays and need only a few fields.&lt;/p&gt;
&lt;h2&gt;Object destructuring&lt;/h2&gt;
&lt;p&gt;Let&apos;s get back to our example &lt;code&gt;student&lt;/code&gt; object.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const student = {
  firstName: &apos;John&apos;,
  secondName: &apos;Doe&apos;,
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A classic way of getting one of the field value is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;student.firstName; // John
// or
student[&apos;firstName&apos;]; // John
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The new syntax allows us to do it in my opinion - a cleaner way.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const { firstName } = student;
firstName; // John
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same thing we can do with &lt;code&gt;secondName&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const { firstName, secondName } = student;
firstName; // John
secondName; // Doe
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One what we need to remember is that we need to know what keys objects store.&lt;/p&gt;
&lt;p&gt;Also, it isn&apos;t a problem to change the key name on the fly.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const { first: firstName, second: secondName } = student;
first; // John
second; // Doe
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But what if we will have a more complex structure? Maybe like this?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const student = {
  firstName: &apos;John&apos;,
  secondName: &apos;Doe&apos;,
  parents: {
    father: {
      firstName: &apos;Joe&apos;,
      secondName: &apos;Doe&apos;,
    },
    // ...
  },
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get &lt;code&gt;father&lt;/code&gt; field, we can as in old way - do it in dot or bracket notation or new way&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const { parents: { father: { firstName } } = student;
firstName // Joe
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;Getting variables using destructuring makes our life a bit easier. It looks nicer than the normal way and makes code reading easier.&lt;/p&gt;
&lt;p&gt;For now, I&apos;m using them more than the old way, and what do you think about it?&lt;/p&gt;
</content:encoded></item><item><title>Automated testing setup for smart contracts: a practical guide</title><link>https://kodziak.com/blog/automated-testing-setup-smart-contracts/</link><guid isPermaLink="true">https://kodziak.com/blog/automated-testing-setup-smart-contracts/</guid><description>Learn how to set up automated testing for your smart contracts, ensuring security and reliability in your blockchain projects.</description><pubDate>Wed, 06 Nov 2024 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Today, we&apos;re diving into the world of automated testing for smart contracts. If you&apos;re building in Web3, you know how crucial it is to have rock-solid code. Let&apos;s explore how to set up a testing environment that&apos;ll make your smart contracts bulletproof! 🛡️&lt;/p&gt;
&lt;h2&gt;Why Automated Testing for Smart Contracts?&lt;/h2&gt;
&lt;p&gt;Before we jump into the how-to, let&apos;s quickly chat about why this is so important:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;: Smart contracts often handle millions of dollars. One tiny bug could be catastrophic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Immutability&lt;/strong&gt;: Once deployed, you can&apos;t just push a quick fix. Testing thoroughly before deployment is key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Complexity&lt;/strong&gt;: DeFi protocols can get pretty wild. Automated tests help manage that complexity.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Alright, let&apos;s get our hands dirty! 🛠️&lt;/p&gt;
&lt;h2&gt;Setting Up Your Testing Environment&lt;/h2&gt;
&lt;p&gt;First things first, we need to choose our tools. For this guide, we&apos;ll use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hardhat: A development environment for Ethereum&lt;/li&gt;
&lt;li&gt;Chai: An assertion library&lt;/li&gt;
&lt;li&gt;Ethers.js: To interact with our contracts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&apos;s set it up:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;npm init -y
npm install --save-dev hardhat chai @nomiclabs/hardhat-ethers ethers
npx hardhat
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Choose &quot;Create a basic sample project&quot; when prompted.&lt;/p&gt;
&lt;h2&gt;Writing Your First Test&lt;/h2&gt;
&lt;p&gt;Let&apos;s say we have a simple &lt;code&gt;Token&lt;/code&gt; contract. Here&apos;s how we might test it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const { expect } = require(&quot;chai&quot;);

describe(&quot;Token contract&quot;, function() {
  it(&quot;Deployment should assign the total supply of tokens to the owner&quot;, async function() {
    const [owner] = await ethers.getSigners();

    const Token = await ethers.getContractFactory(&quot;Token&quot;);

    const hardhatToken = await Token.deploy();

    const ownerBalance = await hardhatToken.balanceOf(owner.address);
    expect(await hardhatToken.totalSupply()).to.equal(ownerBalance);
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test checks if the total supply is assigned to the contract owner upon deployment. Simple, but powerful! 💪&lt;/p&gt;
&lt;h2&gt;Automating Your Tests&lt;/h2&gt;
&lt;p&gt;Now, let&apos;s make sure these tests run automatically. We can use GitHub Actions for this. Create a file &lt;code&gt;.github/workflows/test.yml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;name: Smart Contract Tests

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: &apos;14.x&apos;
      - run: npm ci
      - run: npx hardhat test
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, every time you push to your repo, your tests will run automatically. No more forgetting to test before that big deploy! 😅&lt;/p&gt;
&lt;h2&gt;Best Practices for Smart Contract Testing&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Test Edge Cases&lt;/strong&gt;: Don&apos;t just test the happy path. What happens when things go wrong?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gas Optimization&lt;/strong&gt;: Include tests for gas usage to avoid costly surprises.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fuzz Testing&lt;/strong&gt;: Use tools like Echidna to generate random inputs and find unexpected bugs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simulation&lt;/strong&gt;: For complex DeFi protocols, simulate various market conditions.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Wrapping Up&lt;/h2&gt;
&lt;p&gt;Setting up automated testing for your smart contracts might seem like a hassle at first, but trust me, it&apos;s worth it. It&apos;ll save you from headaches (and possibly heart attacks) down the line.&lt;/p&gt;
&lt;p&gt;Remember, in the world of Web3, code is law. Make sure your law is air-tight! ⚖️&lt;/p&gt;
&lt;p&gt;Happy testing, and may your contracts always compile on the first try! 🚀&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Want to level up your Web3 QA game even more? Check out &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; for advanced testing strategies and tools specifically designed for blockchain projects. Don&apos;t let bugs be the weak link in your Web3 revolution! 💪🔗&lt;/p&gt;
</content:encoded></item><item><title>Creating Test Data for DeFi: Beyond Simple ERC20 Mocks</title><link>https://kodziak.com/blog/creating-test-data-for-defi-beyond-simple-erc20-mocks/</link><guid isPermaLink="true">https://kodziak.com/blog/creating-test-data-for-defi-beyond-simple-erc20-mocks/</guid><description>Learn how to create realistic test data for DeFi projects, moving beyond basic ERC20 mocks to simulate complex financial scenarios and edge cases.</description><pubDate>Thu, 21 Nov 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Ever felt like your test data is as bland as unseasoned tofu? You&apos;re not alone. A whopping 80% of DeFi projects I&apos;ve audited rely solely on basic ERC20 mocks for testing. But in the wild world of decentralized finance, that&apos;s like bringing a knife to a gunfight. Let&apos;s level up your test game! 🚀&lt;/p&gt;
&lt;h2&gt;The Problem with Simple Mocks&lt;/h2&gt;
&lt;p&gt;Picture this: You&apos;ve built an amazing DEX, tested it with your trusty ERC20 mock, and everything&apos;s green. You deploy... and boom! 💥 Real-world tokens with transfer fees, rebasing mechanisms, or non-standard implementations start flowing in, and suddenly your perfectly tested DEX is about as stable as a house of cards in a hurricane.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Don&apos;t do this:
function testSwap() {
  const mockToken = await MockERC20.deploy();
  await dex.swap(mockToken.address, amount);
  // Assert some basic stuff
}

// ✅ Do this instead:
function testSwapWithComplexToken() {
  const complexToken = await DeployComplexToken();
  await dex.swap(complexToken.address, amount);
  // Assert considering token&apos;s unique behavior
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the first example, we&apos;re living in La La Land. In the second, we&apos;re preparing for the DeFi jungle. Let&apos;s dive deeper into creating test data that actually reflects the chaotic beauty of the blockchain.&lt;/p&gt;
&lt;h2&gt;🛠 Crafting Realistic Test Tokens&lt;/h2&gt;
&lt;h3&gt;1. Fee-on-Transfer Tokens&lt;/h3&gt;
&lt;p&gt;Some tokens take a cut on every transfer. Surprise! 🎉&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contract FeeToken is ERC20 {
    uint256 public constant FEE = 100; // 1%

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        uint256 fee = amount * FEE / 10000;
        uint256 actualAmount = amount - fee;
        
        _transfer(_msgSender(), recipient, actualAmount);
        _transfer(_msgSender(), address(this), fee);
        
        return true;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When testing with this bad boy, make sure your contracts can handle receiving less than they expected. It&apos;s like ordering a large pizza and getting a medium - disappointing, but you gotta deal with it.&lt;/p&gt;
&lt;h3&gt;2. Rebasing Tokens&lt;/h3&gt;
&lt;p&gt;These tokens adjust everyone&apos;s balance periodically. It&apos;s like your bank account on steroids (or a crash diet).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contract RebasingToken is ERC20 {
    uint256 public constant REBASE_INTERVAL = 1 hours;
    uint256 public lastRebaseTime;

    function rebase() public {
        if (block.timestamp &amp;gt;= lastRebaseTime + REBASE_INTERVAL) {
            uint256 supply = totalSupply();
            _mint(address(this), supply / 100); // 1% inflation
            lastRebaseTime = block.timestamp;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Testing tip: Make sure to simulate time passages and check how your contracts handle sudden balance changes. It&apos;s like testing your app&apos;s resilience to users who can&apos;t make up their minds.&lt;/p&gt;
&lt;h3&gt;3. Blacklistable Tokens&lt;/h3&gt;
&lt;p&gt;Some tokens come with a built-in bouncer. No entry for you! 🚫&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contract BlacklistableToken is ERC20 {
    mapping(address =&amp;gt; bool) public blacklist;
    
    function transfer(address recipient, uint256 amount) public override returns (bool) {
        require(!blacklist[msg.sender] &amp;amp;&amp;amp; !blacklist[recipient], &quot;Blacklisted!&quot;);
        return super.transfer(recipient, amount);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When testing, try to swap or provide liquidity with blacklisted addresses. Your contract should handle rejection gracefully, like a seasoned bouncer at an exclusive club.&lt;/p&gt;
&lt;h2&gt;🎭 Simulating Real-World Scenarios&lt;/h2&gt;
&lt;p&gt;Now that we have our exotic token menagerie, let&apos;s put them through their paces:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Liquidity Crunches&lt;/strong&gt;: Simulate a sudden drain of liquidity. How does your AMM handle it?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flash Loan Attacks&lt;/strong&gt;: Use your test tokens in a flash loan scenario. Can your protocol withstand the pressure?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gas Price Spikes&lt;/strong&gt;: Mimic Ethereum congestion by manipulating gas prices in your tests. Does your contract prioritize transactions correctly?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here&apos;s a quick example of simulating a liquidity crunch:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;async function testLiquidityCrunch() {
  const complexToken = await DeployComplexToken();
  const pair = await factory.createPair(weth.address, complexToken.address);
  
  // Provide initial liquidity
  await addLiquidity(weth, complexToken, ethers.utils.parseEther(&quot;100&quot;), ethers.utils.parseEther(&quot;10000&quot;));
  
  // Simulate large withdrawal
  await pair.connect(whale).burn(await pair.balanceOf(whale.address));
  
  // Now try to swap
  await expect(
    router.swapExactTokensForTokens(
      ethers.utils.parseEther(&quot;1&quot;),
      0,
      [weth.address, complexToken.address],
      user.address,
      (await ethers.provider.getBlock(&apos;latest&apos;)).timestamp + 1000
    )
  ).to.be.revertedWith(&quot;Insufficient Liquidity&quot;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test ensures your DEX doesn&apos;t implode when the liquidity suddenly decides to go on vacation.&lt;/p&gt;
&lt;h2&gt;🧠 Why This Matters&lt;/h2&gt;
&lt;p&gt;Creating diverse and realistic test data isn&apos;t just about being a perfectionist (though that helps in DeFi). It&apos;s about:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Anticipating the Unexpected&lt;/strong&gt;: DeFi is where traditional finance meets the Wild West. Prepare for anything.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Building Trust&lt;/strong&gt;: Robust testing translates to reliable protocols. Users trust what doesn&apos;t break.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Saving Time (and ETH)&lt;/strong&gt;: Catching bugs in testnet is way cheaper than explaining to users why their funds are now part of a very expensive lesson.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;🚀 Leveling Up Your Testing Game&lt;/h2&gt;
&lt;p&gt;Ready to take your DeFi testing to the next level? Here are your marching orders:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Audit your test suite. How many different token types are you really testing against?&lt;/li&gt;
&lt;li&gt;Create a &quot;token zoo&quot; - a collection of various token implementations to test against.&lt;/li&gt;
&lt;li&gt;Simulate extreme market conditions. What happens to your protocol during a market crash?&lt;/li&gt;
&lt;li&gt;Consider property-based testing to uncover edge cases you haven&apos;t even thought of yet.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Remember, in DeFi, we&apos;re not just building financial applications; we&apos;re architecting the future of finance. Every test you write is a brick in the foundation of that future.&lt;/p&gt;
&lt;p&gt;Hungry for more DeFi testing wisdom? Want to make your protocols as robust as a cockroach in a nuclear winter? Swing by &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; for more advanced testing strategies, war stories from the trenches, and a community of battle-hardened DeFi testers. Let&apos;s make DeFi unbreakable, one test at a time! 💪🚀&lt;/p&gt;
</content:encoded></item><item><title>First steps with end-to-end testing using jest + playwright (puppeteer)</title><link>https://kodziak.com/blog/first-steps-with-e2e-testing-using-jest-playwright/</link><guid isPermaLink="true">https://kodziak.com/blog/first-steps-with-e2e-testing-using-jest-playwright/</guid><description>Recently I wrote a post about my first steps with test automation. I tried to answer questions related to the topic and guide you where and what to search for. Now, I want to expand on it with technical steps</description><pubDate>Thu, 03 Dec 2020 17:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;This post is a continuation of the “&lt;a href=&quot;https://kodziak.com/blog/first-steps-with-test-automation&quot;&gt;First steps with test automation&lt;/a&gt;” article.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Recently I wrote a post about my first steps with test automation. I tried to answer questions related to the topic and guide you where and what to search for (if you&apos;re interested - &lt;a href=&quot;https://kodziak.com/blog/first-steps-with-test-automation&quot;&gt;click here!&lt;/a&gt;). Now, I want to expand on it with technical steps you need to take and show you how easily you can create a basic test with a real world example (my blog 🥳).&lt;/p&gt;
&lt;p&gt;We will create a base repository with &lt;strong&gt;Playwright&lt;/strong&gt; and &lt;strong&gt;JestJS&lt;/strong&gt; and write a basic test which will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Load the blog page,&lt;/li&gt;
&lt;li&gt;Check if the blog title contains the author’s name,&lt;/li&gt;
&lt;li&gt;Check if the posts list isn&apos;t empty,&lt;/li&gt;
&lt;li&gt;Click on the first post title and check if it loaded correctly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To achieve it, I think you need a little more knowledge, so I split the article into three topics (+bonus):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What do I need to start with automation?&lt;/li&gt;
&lt;li&gt;Project setup with &lt;strong&gt;Playwright&lt;/strong&gt; and &lt;strong&gt;JestJS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Let&apos;s write an automated test&lt;/li&gt;
&lt;li&gt;Bonus: Test recorder!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before starting the game, here are some topics which you should be familiar with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Basic knowledge of JavaScript,&lt;/li&gt;
&lt;li&gt;You know how to use CLI and NPM/Yarn,&lt;/li&gt;
&lt;li&gt;You&apos;re familiar with HTML/CSS.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What do I need to start with automatization?&lt;/h3&gt;
&lt;p&gt;First of all, you need a library/tool which allows you to control a browser using code. Today, I&apos;ll use NodeJS library called &lt;strong&gt;Playwright&lt;/strong&gt; (which is very similar to &lt;strong&gt;Puppeteer&lt;/strong&gt; – here you can find a nice article about the differences: &lt;a href=&quot;https://blog.logrocket.com/playwright-vs-puppeteer/&quot;&gt;https://blog.logrocket.com/playwright-vs-puppeteer/&lt;/a&gt;) to automate our actions with an API. You need a tool like this to write tests that will imitate the behaviour of end user (behave like our clients).&lt;/p&gt;
&lt;p&gt;Basically, doing a test manually, you&apos;re using a mouse to click and scroll or a keyboard to fill in the forms. In automated tests, you&apos;re using a library API to do the same things but the browser is controlled by automation software, not a user.&lt;/p&gt;
&lt;p&gt;Next, we need assertions. &lt;strong&gt;Playwright&lt;/strong&gt; provides their own ones, but honestly – I&apos;ve never used them. I like &lt;strong&gt;JestJS&lt;/strong&gt;, which, besides that, is a test runner, which gives you more opportunities to control the whole test base. With an easy way to do parallelisation or configs for dev/production envs, writing tests is only a pleasure 🥰.&lt;/p&gt;
&lt;p&gt;In summary, you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A library to control a browser → we&apos;ll use &lt;strong&gt;Playwright&lt;/strong&gt;,&lt;/li&gt;
&lt;li&gt;A test runner → we&apos;ll use &lt;strong&gt;JestJS&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Project setup with Playwright and JestJS&lt;/h3&gt;
&lt;p&gt;So we will use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://playwright.dev/&quot;&gt;Playwright&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jestjs.io/en/&quot;&gt;JestJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/playwright-community/jest-playwright&quot;&gt;Jest-Playwright&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And if you decided to stick with puppeteer:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://pptr.dev/&quot;&gt;Puppeteer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/smooth-code/jest-puppeteer&quot;&gt;Jest-Puppeteer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When using puppeteer, you need to change selectors because the API is slighty different. In our basic test, it is enough to remove &lt;code&gt;css=&lt;/code&gt; part and change &lt;code&gt;waitForLoadState&lt;/code&gt; ⇒ &lt;code&gt;waitForNavigation&lt;/code&gt;. After those two changes, everything should work.&lt;/p&gt;
&lt;p&gt;Before we start writing our first automated test, we need to set up the repository:&lt;/p&gt;
&lt;p&gt;Let&apos;s initialize it first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;yarn init&lt;/code&gt; or &lt;code&gt;npm install&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then install the required dependencies:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;yarn install jest jest-playwright-preset playwright&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;p&gt;&lt;code&gt;npm install jest jest-playwright-preset playwright&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And create two config files,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// jest.config.js
module.exports = {
  preset: &apos;jest-playwright-preset&apos;,
};
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;// jest-playwright.config.js
module.exports = {
  // Describe which browsers we want to run
  browsers: [&apos;chromium&apos;, &apos;firefox&apos;, &apos;webkit&apos;],
  launchOptions: {
    // If we want to run browsers in headless mode or not,
    headless: false,
    // If we want to have opened devtools from start
    devtools: false,
  },
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also, we need to an execute script to our &lt;code&gt;package.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;scripts&quot;: {
    &quot;test&quot;: &quot;jest&quot;
  },
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, you can &lt;code&gt;yarn test&lt;/code&gt; or &lt;code&gt;npm run test&lt;/code&gt; which will run all files matching &lt;code&gt;*.test.js&lt;/code&gt; names – but we don&apos;t have any tests yet 🙈&lt;/p&gt;
&lt;p&gt;One more thing that I added is &lt;code&gt;tests/&lt;/code&gt; directory where we will store our test.&lt;/p&gt;
&lt;h3&gt;Let&apos;s write an automated test&lt;/h3&gt;
&lt;p&gt;First we need to know what we want to test 🙈&lt;/p&gt;
&lt;p&gt;I created a basic flow relating to my blog, which you&apos;re reading now:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check if the blog title contains the author’s name,&lt;/li&gt;
&lt;li&gt;Check if the posts list isn&apos;t empty,&lt;/li&gt;
&lt;li&gt;Click on the first post title and check if it loaded correctly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the directory &lt;code&gt;tests/&lt;/code&gt; I added a file &lt;code&gt;example.test.js&lt;/code&gt;. And to make it easier for you, I coded the above scenario, adding comments line by line, describing what’s happening.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;let blogPosts = [];

describe(&apos;Blog - kodziak.com/blog/&apos;, () =&amp;gt; {
  // Will trigger methods before tests
  beforeAll(async () =&amp;gt; {
    // Load blog page
    await page.goto(&apos;https://kodziak.com/blog/&apos;);
  });

  test(&apos;title should be &quot;Blog | Przemysław Paczoski&quot;&apos;, async () =&amp;gt; {
    // Get website title
    const title = await page.title();

    // Compare title of current page
    expect(title).toBe(&apos;Blog | Przemysław Paczoski&apos;);
  });

  test(&apos;should display list of blog posts&apos;, async () =&amp;gt; {
    // Get all blog posts as an array of objects
    blogPosts = await page.$$eval(&apos;css=.post&apos;, elems =&amp;gt;
      elems.map(el =&amp;gt; {
        return {
          title: el.querySelector(&apos;.post-title&apos;).textContent.trim(),
          description: el.querySelector(&apos;.post-description&apos;).textContent.trim(),
          href: el.href,
        };
      })
    );

    // Check if list length is greater than 0
    expect(blogPosts.length).toBeGreaterThan(0);
  });

  test(&apos;click on blog post should redirect to article&apos;, async () =&amp;gt; {
    // Go to first blog post, there we&apos;re waiting to resolve all promises from array
    await Promise.all([
      // Click oo .post-title css class element
      page.click(&apos;css=.post-title&apos;),
      // Wait for networkidle event, promise resolves after event
      page.waitForLoadState(&apos;networkidle&apos;),
    ]);

    // Get title, content and href of current article
    const [articleTitle, articleContent, articleHref] = await Promise.all([
      // Get article title, we use here array destructuring
      page.$eval(&apos;css=h2&apos;, el =&amp;gt; el.textContent.trim()),
      // Get article content
      page.$eval(&apos;css=.content&apos;, el =&amp;gt; el.textContent),
      // Get article href
      page.url(),
    ]);

    // Destructuring first element from an blog posts array. First we use array destructuring and then object destructuring
    const [{ title, description, href }] = blogPosts;

    // Compare title from posts list with current article&apos;s title
    expect(title).toBe(articleTitle);
    // Check if the current article content includes description from posts list, compare output with boolean true
    expect(articleContent.includes(description)).toBe(true);
    // Compare href from posts list with current article&apos;s href
    expect(href).toBe(articleHref);
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After we finish coding our test, let&apos;s run it using the command &lt;code&gt;yarn test&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Playwright will open three browsers which we described earlier: &lt;code&gt;chromium&lt;/code&gt;, &lt;code&gt;firefox&lt;/code&gt;, &lt;code&gt;webkit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;And if everything goes well, we should see the following log:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And that&apos;s it! We ran our tests positively in three different browsers.&lt;/p&gt;
&lt;h3&gt;Bonus: Test recorder!&lt;/h3&gt;
&lt;p&gt;Lastly, a good way to start with test automation could be to use test recorders. Nice one, created with playwright is: &lt;a href=&quot;https://github.com/microsoft/playwright-cli&quot;&gt;https://github.com/microsoft/playwright-cli&lt;/a&gt; which allows you to record your browser interactions and automatically generate a fully working code – an automated test with &lt;strong&gt;Playwright&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this article, I wanted to show you how easy it is to automate a basic test scenario using tools such as &lt;strong&gt;Playwright&lt;/strong&gt; and &lt;strong&gt;JestJS&lt;/strong&gt;. I hope that will be a good start for you to explore this part of software engineering.&lt;/p&gt;
&lt;p&gt;After reading it, you should have learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What Playwright (Puppeteer) and JestJS are used for,&lt;/li&gt;
&lt;li&gt;How to set up a repository using those technologies,&lt;/li&gt;
&lt;li&gt;How to write a basic test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fully working, implemented code from this article can be found in my repository: &lt;a href=&quot;https://github.com/Kodziak/playwright-first-steps&quot;&gt;https://github.com/Kodziak/playwright-first-steps&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Have a nice day!&lt;/p&gt;
</content:encoded></item><item><title>First steps with UI test automation</title><link>https://kodziak.com/blog/first-steps-with-test-automation/</link><guid isPermaLink="true">https://kodziak.com/blog/first-steps-with-test-automation/</guid><description>Starting your test automation journey isn&apos;t always as smooth as it should be. You may have a lot of questions like</description><pubDate>Thu, 26 Nov 2020 09:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Starting your test automation journey isn&apos;t always as smooth as it should be. You may have a lot of questions like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do I have to be a manual tester before?&lt;/li&gt;
&lt;li&gt;What language should I start with?&lt;/li&gt;
&lt;li&gt;What framework/library should I pick?&lt;/li&gt;
&lt;li&gt;What to automate first?&lt;/li&gt;
&lt;li&gt;Where to search for information?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and probably many more. I&apos;ll try to answer all of them based on my experience and the steps I took when I started with automated functional tests.&lt;/p&gt;
&lt;p&gt;So my case was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;experience with manual tests,&lt;/li&gt;
&lt;li&gt;no programming background,&lt;/li&gt;
&lt;li&gt;the team wanted to start with test automation,&lt;/li&gt;
&lt;li&gt;the business was convinced that test automation would be useful.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And I’m going to write this article from that perspective.&lt;/p&gt;
&lt;h3&gt;Do I have to be a manual tester before?&lt;/h3&gt;
&lt;p&gt;The short answer is: it would be helpful.&lt;/p&gt;
&lt;p&gt;I started my adventure as an intern manual tester and after quite a short time I moved to junior quality assurance position. The whole job was to perform and execute manual tests. I was doing it only for about half a year and then decided to go with automation. I knew that some regression cases could be easily automated and give me more time for other tests. And in my opinion it&apos;s a good place to start with automation. It will save you a lot of time for testing new features and probably shorten your time to market.&lt;/p&gt;
&lt;p&gt;When you start with manual tests first, you’ll most certainly learn how to write a good test case which is a very important skill. I mean, doing it manually you’re checking specific elements and behaviours of the application so with this knowledge it would be much easier to write good automated tests. If you skip the part of being a manual tester, you will have to catch up – so another topic for beginners:)&lt;/p&gt;
&lt;p&gt;That&apos;s why, in my opinion, it is important and could be very helpful to start as a manual tester, learn how to test, and then start with automation testing.&lt;/p&gt;
&lt;h3&gt;What programming language should I pick?&lt;/h3&gt;
&lt;p&gt;Like everything, it depends. When starting with test automation it’s good to have buddies in the team who could help you. It&apos;s possible if you&apos;re writing tests in the same language as they&apos;re using. I started like that and in my opinion this is the best way.&lt;/p&gt;
&lt;p&gt;So, you&apos;re working in a scrum team, you&apos;re writing front-end applications and you have to write UI tests without a programming background. Having those prerequisites, I would go with a language that my teammates know. Especially in the beginning, they could help you to set up the architecture and write the first test. From a developer’s perspective, learning how another framework/library works is kinda easy. And problems we could face may vary – a problem with framework and a variable not being passed, bad syntax or wrong if statement. Having a bunch of people that could help you in those situations is priceless.&lt;/p&gt;
&lt;p&gt;Another nice thing is that the whole team could write test scripts. We are all working to make the application as good as we can, so why couldn’t a developer update a test script after it was affected by his/her changes to UI. And having gone through a given test scenario, he/she could write a whole test. It would speed up our work and let us exchange knowledge. It&apos;s very beneficial when you&apos;re not the only person who can maintain the test base.&lt;/p&gt;
&lt;p&gt;We all want to have a bug free product (and we all know it&apos;s impossible).&lt;/p&gt;
&lt;h3&gt;What framework/library?&lt;/h3&gt;
&lt;p&gt;Of course it depends on the programming language you have chosen. Here are the most popular solutions and combinations which I know (together with links to documentation):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Java ⇒ &lt;a href=&quot;https://www.selenium.dev/documentation/en/&quot;&gt;Selenium&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;C# ⇒ &lt;a href=&quot;https://www.selenium.dev/documentation/en/&quot;&gt;Selenium&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;JavaScript/TypeScript ⇒ &lt;a href=&quot;https://jestjs.io/docs/en/puppeteer&quot;&gt;Jest&lt;/a&gt; + &lt;a href=&quot;https://pptr.dev/&quot;&gt;Puppeteer&lt;/a&gt;, &lt;a href=&quot;https://www.cypress.io/&quot;&gt;Cypress&lt;/a&gt;, &lt;a href=&quot;https://devexpress.github.io/testcafe/&quot;&gt;TestCafe&lt;/a&gt;, &lt;a href=&quot;https://www.selenium.dev/documentation/en/&quot;&gt;Selenium&lt;/a&gt;, &lt;a href=&quot;https://nightwatchjs.org/&quot;&gt;Nightwatch&lt;/a&gt;, &lt;a href=&quot;https://www.protractortest.org/#/&quot;&gt;Protractor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Python ⇒ &lt;a href=&quot;https://robotframework.org/&quot;&gt;Robot Framework&lt;/a&gt;, &lt;a href=&quot;https://www.selenium.dev/documentation/en/&quot;&gt;Selenium&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can notice that Selenium gives you the opportunity to write in almost any language you want. And overall it&apos;s a nice solution with another big plus: most of the problems you’ll face with it have already been solved on StackOverflow, which is very helpful in the beginning.&lt;/p&gt;
&lt;h3&gt;What to automate first?&lt;/h3&gt;
&lt;p&gt;I&apos;ve already mentioned manual testing and regression. As we all know, regression is kinda repeatable. Many times, we&apos;re doing the same cases all over again which is quite boring. Also, it requires quite some time: sometimes a few hours, sometimes days. So if we write all the cases as automated we could save a lot of time for feature tests and reduce time to market.&lt;/p&gt;
&lt;p&gt;Regression test cases aren&apos;t very dynamic either. I mean, we probably won&apos;t be changing half of the tests by deployment. They don&apos;t need much maintenance time.&lt;/p&gt;
&lt;p&gt;Reduced time to market is also an important thing related to automated regression testing. Doing it manually could take, for example, two days, and when we switch to automation, we could make it, for example, one hour. It&apos;s very beneficial for business, which could be an argument for starting the automation. And one hour is still a pretty long time, in my opinion. Using parallelization or other techniques we could shorten it down to a few minutes. But it depends – of course.&lt;/p&gt;
&lt;p&gt;So I would start with regression and probably with login test cases. It’s repeatable, well-known and not so hard.&lt;/p&gt;
&lt;h3&gt;Where to search for information?&lt;/h3&gt;
&lt;p&gt;I would stick to the official documentation, which is linked above, but you can also use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/&quot;&gt;stackoverflow.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.guru99.com/software-testing.html&quot;&gt;https://www.guru99.com/software-testing.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.softwaretestinghelp.com/automation-testing-tutorial-1/&quot;&gt;https://www.softwaretestinghelp.com/automation-testing-tutorial-1/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://medium.com/&quot;&gt;medium.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are two aggregates of links and general websites which could be helpful. Honestly, most of the time I&apos;m using the first two ones because typing any problem into Google will probably return a solution from StackOverflow.&lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;I hope I answered the given questions, but let&apos;s sum it up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Do I have to be manual tester before?&lt;/strong&gt; → in my opinion, it’s very helpful but not necessary,&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What language should I start with?&lt;/strong&gt; → pick the language that your team knows,&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What framework/library should I pick?&lt;/strong&gt; → related to the chosen language, the list above,&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What to automate first?&lt;/strong&gt; → regression tests and login test case are kinda nice to start with,&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Where to search for information?&lt;/strong&gt; → documentation + Google and StackOverflow for problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&apos;s just my opinion based on my own experience. If I had to start with automation again, I&apos;d do the same, with those prerequisites. But of course – you have to adjust these steps to your business, type of work, and the situation you’re in.&lt;/p&gt;
&lt;p&gt;Have a nice day!&lt;/p&gt;
</content:encoded></item><item><title>Gas optimization through testing: how we reduced costs by 40%</title><link>https://kodziak.com/blog/gas-optimization-through-testing/</link><guid isPermaLink="true">https://kodziak.com/blog/gas-optimization-through-testing/</guid><description>Discover how we slashed gas costs by 40% using smart contract testing techniques. Learn practical tips for optimizing your own Web3 projects.</description><pubDate>Wed, 13 Nov 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Ever felt that punch in the gut when you deploy your smart contract, only to watch gas costs skyrocket? 😱 You&apos;re not alone. In fact, a whopping 80% of Web3 projects struggle with high gas fees, often due to unoptimized code.&lt;/p&gt;
&lt;p&gt;But here&apos;s the kicker - we managed to slash our gas costs by 40% through smart testing. Yep, you read that right. Let&apos;s dive into how we did it, shall we?&lt;/p&gt;
&lt;h2&gt;The Problem: Gas Guzzling Contracts 🚗💨&lt;/h2&gt;
&lt;p&gt;First things first, let&apos;s look at a typical gas-hungry function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Gas guzzler alert!
function distributeBonuses(address[] memory employees) public {
    for (uint i = 0; i &amp;lt; employees.length; i++) {
        uint bonus = calculateBonus(employees[i]);
        payable(employees[i]).transfer(bonus);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This function looks innocent enough, but it&apos;s a silent killer for your gas budget. Why? It&apos;s doing separate transfers for each employee, and that&apos;s expensive on Ethereum.&lt;/p&gt;
&lt;h2&gt;The Solution: Batch Those Transfers! 🚀&lt;/h2&gt;
&lt;p&gt;Here&apos;s how we optimized it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ✅ Gas saver extraordinaire
function distributeBonuses(address[] memory employees, uint[] memory bonuses) public {
    require(employees.length == bonuses.length, &quot;Arrays must be same length&quot;);
    
    for (uint i = 0; i &amp;lt; employees.length; i++) {
        payable(employees[i]).transfer(bonuses[i]);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What&apos;s the difference? We&apos;re now passing in pre-calculated bonuses, eliminating the need for separate &lt;code&gt;calculateBonus&lt;/code&gt; calls for each employee. This might seem small, but in a large organization, it can save a ton of gas.&lt;/p&gt;
&lt;h2&gt;The Testing Strategy 🧪&lt;/h2&gt;
&lt;p&gt;Now, how did we catch this? Enter: Gas Optimization Tests. We set up a test suite that specifically targets gas usage. Here&apos;s a simplified version:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { expect } from &quot;chai&quot;;
import { ethers } from &quot;hardhat&quot;;

describe(&quot;BonusDistributor&quot;, function () {
  it(&quot;should optimize gas for bonus distribution&quot;, async function () {
    const BonusDistributor = await ethers.getContractFactory(&quot;BonusDistributor&quot;);
    const bonusDistributor = await BonusDistributor.deploy();

    const employees = [addr1.address, addr2.address, addr3.address];
    const bonuses = [100, 200, 300];

    const tx = await bonusDistributor.distributeBonuses(employees, bonuses);
    const receipt = await tx.wait();

    expect(receipt.gasUsed).to.be.below(100000); // Set your gas limit here
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test ensures that our &lt;code&gt;distributeBonuses&lt;/code&gt; function stays under a specific gas limit. If it ever creeps up, we&apos;ll catch it before deployment.&lt;/p&gt;
&lt;h2&gt;The Results: 40% Gas Savings 💰&lt;/h2&gt;
&lt;p&gt;By implementing this and similar optimizations across our codebase, we saw a dramatic 40% reduction in gas costs. Here&apos;s a quick before and after:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;th&gt;Savings&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10 employees&lt;/td&gt;
&lt;td&gt;500,000 gas&lt;/td&gt;
&lt;td&gt;300,000 gas&lt;/td&gt;
&lt;td&gt;40%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100 employees&lt;/td&gt;
&lt;td&gt;5,000,000 gas&lt;/td&gt;
&lt;td&gt;3,000,000 gas&lt;/td&gt;
&lt;td&gt;40%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Key Takeaways 🗝️&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Always batch operations&lt;/strong&gt; when possible&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implement gas-specific tests&lt;/strong&gt; in your CI/CD pipeline&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Profile your contracts&lt;/strong&gt; regularly to catch gas hogs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Consider off-chain calculations&lt;/strong&gt; to reduce on-chain complexity&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;What&apos;s Next? 🚀&lt;/h2&gt;
&lt;p&gt;Gas optimization is an ongoing process. As your project evolves, keep testing and refining. And remember, every little optimization counts!&lt;/p&gt;
&lt;p&gt;Struggling with high gas costs in your Web3 project? Don&apos;t sweat it! At web3qa.xyz, we specialize in helping teams like yours slash gas costs and optimize smart contracts. Let&apos;s chat about how we can supercharge your project&apos;s efficiency!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://web3qa.xyz&quot;&gt;Check out web3qa.xyz&lt;/a&gt; to learn more about our Web3 testing and optimization services. Your future self (and your users&apos; wallets) will thank you! 💪&lt;/p&gt;
</content:encoded></item><item><title>How much does web3 testing really cost? Breaking down the numbers</title><link>https://kodziak.com/blog/how-much-does-web3-testing-really-cost/</link><guid isPermaLink="true">https://kodziak.com/blog/how-much-does-web3-testing-really-cost/</guid><description>Dive deep into the real costs of Web3 testing, including hidden expenses and budget-saving strategies for blockchain projects.</description><pubDate>Thu, 31 Oct 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Today, we&apos;re gonna crunch some numbers and get real about the costs of testing in the Web3 world. Buckle up, &apos;cause this might surprise you (and your CFO)!&lt;/p&gt;
&lt;h2&gt;The True Cost of Web3 Testing: It&apos;s Not Just About the Tools 🧰&lt;/h2&gt;
&lt;p&gt;When we talk about Web3 testing costs, it&apos;s easy to focus on the obvious stuff - like test automation tools or fancy blockchain simulators. But let&apos;s be real, the actual expenses go way beyond that. Here&apos;s what you need to consider:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Smart Contract Audits&lt;/strong&gt;: This ain&apos;t your grandma&apos;s code review. Expect to shell out anywhere from $5,000 to $50,000+ depending on complexity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Specialized Talent&lt;/strong&gt;: Web3 devs and QA engineers don&apos;t come cheap. Annual salaries can easily hit $150,000+.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gas Fees&lt;/strong&gt;: Yep, even testing costs gas. For complex DApps, this can add up to hundreds or even thousands of dollars per month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Infrastructure&lt;/strong&gt;: Running nodes, managing testnets - it all adds up. Budget at least a few hundred bucks monthly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security Tools&lt;/strong&gt;: Blockchain-specific security scanners can cost $500-$2000 per month.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Hidden Costs That&apos;ll Sneak Up On Ya 🕵️‍♂️&lt;/h2&gt;
&lt;p&gt;Here&apos;s where it gets tricky. These sneaky expenses often slip under the radar:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Learning Curve&lt;/strong&gt;: Your team needs time to get up to speed. Factor in at least a month of reduced productivity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blockchain-Specific Bugs&lt;/strong&gt;: These can be nasty and time-consuming. Budget extra time for debugging.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testnet Instability&lt;/strong&gt;: When testnets go down, so does your productivity. Always have a Plan B.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Show Me The Code: A Real-World Example 💻&lt;/h2&gt;
&lt;p&gt;Let&apos;s break down a typical test scenario for a DeFi project:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;describe(&apos;Liquidity Pool&apos;, () =&amp;gt; {
  it(&apos;should allow deposits and calculate shares correctly&apos;, async () =&amp;gt; {
    const depositAmount = ethers.utils.parseEther(&apos;10&apos;);
    await token.approve(pool.address, depositAmount);
    await pool.deposit(depositAmount);

    const userShares = await pool.balanceOf(user.address);
    expect(userShares).to.equal(depositAmount);
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Looks simple, right? But here&apos;s what it actually costs to run:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gas fees for approvals and deposits&lt;/li&gt;
&lt;li&gt;Time to set up mock environments&lt;/li&gt;
&lt;li&gt;Potential issues with testnet stability&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All this for just one test! Now multiply that by hundreds of test cases, and you&apos;ll see why proper budgeting is crucial.&lt;/p&gt;
&lt;h2&gt;Strategies to Keep Costs in Check 💰&lt;/h2&gt;
&lt;p&gt;Don&apos;t panic! Here are some pro tips to keep your testing budget from exploding:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Local Blockchain Simulators&lt;/strong&gt;: Tools like Ganache can slash your gas fees during development.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Implement Proper CI/CD&lt;/strong&gt;: Catch issues early to save on costly late-stage fixes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prioritize Test Cases&lt;/strong&gt;: Focus on critical paths first. Not everything needs 100% coverage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Invest in Training&lt;/strong&gt;: A skilled team is more efficient and catches issues faster.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Consider Managed Services&lt;/strong&gt;: Sometimes, outsourcing specific testing tasks can be more cost-effective.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;The Bottom Line: What Should You Budget? 🤔&lt;/h2&gt;
&lt;p&gt;For a mid-sized Web3 project, here&apos;s a rough annual breakdown:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Smart Contract Audits: $30,000&lt;/li&gt;
&lt;li&gt;QA Team (2 engineers): $300,000&lt;/li&gt;
&lt;li&gt;Tools and Infrastructure: $20,000&lt;/li&gt;
&lt;li&gt;Misc. Expenses (gas, security, etc.): $50,000&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Total: Around $400,000 per year&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Sounds like a lot? Well, consider the alternative - a single major bug could cost you millions in lost funds or reputation damage. Suddenly, that testing budget doesn&apos;t seem so bad, eh?&lt;/p&gt;
&lt;h2&gt;Wrapping Up: The Real Value of Web3 Testing&lt;/h2&gt;
&lt;p&gt;At the end of the day, proper testing isn&apos;t just a cost - it&apos;s an investment in your project&apos;s future. Sure, the numbers might make your accountant sweat, but the peace of mind and user trust you gain? Priceless.&lt;/p&gt;
&lt;p&gt;Remember, in the wild west of Web3, it&apos;s not just about launching fast - it&apos;s about launching right. So budget wisely, test thoroughly, and watch your project thrive! 🚀&lt;/p&gt;
&lt;p&gt;Curious about optimizing your Web3 testing strategy without breaking the bank? Check out &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; for expert insights and cost-effective solutions tailored for the blockchain world. Let&apos;s make your Web3 project bulletproof - without needing a money printer! 💪&lt;/p&gt;
</content:encoded></item><item><title>How to make your UI automation tests resilient to changes?</title><link>https://kodziak.com/blog/how-to-make-your-ui-automation-tests-resilient-to-changes/</link><guid isPermaLink="true">https://kodziak.com/blog/how-to-make-your-ui-automation-tests-resilient-to-changes/</guid><description>Using CSS selectors to get elements in end-to-end tests is the most common way (besides xpath), but it can also be tricky and hard to maintain. One day everything could work fine and another a CSS class could be renamed. Styles could change without touching the business flow and then we could have a problem - we&apos;ll need to maintain the tests. Of course, the developers could do those changes for us, but they don&apos;t know our scenarios, our tests etc. It would be time-consuming for them, because they don&apos;t always know if their changes could affect our tests. And for these problems, I think I might have a solution.</description><pubDate>Sun, 20 Dec 2020 14:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Using CSS selectors to get elements in end-to-end tests is the most common way (besides xpath), but it can also be tricky and hard to maintain. One day everything could work fine and another a CSS class could be renamed. Styles could change without touching the business flow and then we could have a problem - we&apos;ll need to maintain the tests. Of course, the developers could do those changes for us, but they don&apos;t know our scenarios, our tests etc. It would be time-consuming for them, because they don&apos;t always know if their changes could affect our tests. And for these problems, I think I might have a solution.&lt;/p&gt;
&lt;p&gt;But first let&apos;s talk about CSS a bit.&lt;/p&gt;
&lt;h2&gt;What are the common problems with CSS selectors?&lt;/h2&gt;
&lt;p&gt;Imagine that one day, you had to write a very ugly selector. The element you wanted to use was nested and the only solution available was to base it on CSS classes and HTML structure. And then, a developer made a little refactor that removed some useless HTML tags, which were of course, used in your selector. But he didn&apos;t change the business flow. And guess what will happen? Yes, you&apos;re right! The test will fail. Your selector will be broken and will need maintenance.&lt;/p&gt;
&lt;p&gt;But let&apos;s take a step back and think about what are CSS classes designed for? For sure, not to use them in end-to-end tests. Why? Because they&apos;re designed to style elements. Everyday there might be changes in the application that don&apos;t affect the business flow - which is the most important part in end-to-end tests - but are related with class names changes. That hurts when we need to maintain a test that didn&apos;t involve any user flow changes.&lt;/p&gt;
&lt;p&gt;Two examples, one simple solution - find better a mechanism to get elements.&lt;/p&gt;
&lt;p&gt;What do I recommend? Read below!&lt;/p&gt;
&lt;h2&gt;Use &lt;code&gt;data-test-id&lt;/code&gt; for help!&lt;/h2&gt;
&lt;p&gt;For sure, they&apos;re controversial but there are two main advantages of using them.&lt;/p&gt;
&lt;p&gt;First one is that they&apos;re bulletproof. What? I mean, when we use this attribute with an element, no matter if the developer changes the HTML structure or CSS classes, we still get what we want. Unless they remove the element or change the business flow, our test should work fine.&lt;/p&gt;
&lt;p&gt;And second, as you may notice, the developer will see that attribute while working with the code. It could help because they can notify us about possible changes or just maintain the tests if needed - using &lt;code&gt;data-test-id&lt;/code&gt; makes it easier find occurrences in tests. And if we have more people working on end-to-end tests we can build more reliable solutions. That&apos;s what we all want to achieve - always working product:)&lt;/p&gt;
&lt;p&gt;More about working closely with developers below:)&lt;/p&gt;
&lt;h2&gt;But should I use them everywhere?&lt;/h2&gt;
&lt;p&gt;Nope. Only with the elements used in tests. We don&apos;t want a mess in the code where almost every element has this attribute and only a few of them is used in tests. We want to build trust towards the tests and somehow show the devs that their changes could break our work.&lt;/p&gt;
&lt;p&gt;Of course, we&apos;ll add some code, but with &lt;code&gt;babel&lt;/code&gt; or similar solution we&apos;ll get rid of &lt;code&gt;data-test-id&lt;/code&gt; on production version. Also, you can take a look at &lt;code&gt;facebook&lt;/code&gt; where these attributes are used;).&lt;/p&gt;
&lt;p&gt;A little bit of extra work can bring us many benefits.&lt;/p&gt;
&lt;h2&gt;What are the benefits of using them?&lt;/h2&gt;
&lt;p&gt;For sure, we can build communication between us and developers. How? Talk. If they see this kind of attribute with an element they want to refactor, they have to maintain the test (in the best case) or just notify us that something could affect it. It&apos;s beneficial to know when something can break our tests before running them on testing environment. It&apos;ll build trust to the tests. They won&apos;t fail because of changes which don&apos;t affect the business flow. It will help all of us.&lt;/p&gt;
&lt;p&gt;The only thing we need to do is give the developers an opportunity and reason to maintain the tests.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Code structure can always change and it shouldn&apos;t affect our tests unless the business flow changes. With selectors based on CSS it could. That&apos;s why we decided to go with &lt;code&gt;data-test-id&lt;/code&gt; which seems like a reliable solution.&lt;/p&gt;
&lt;p&gt;They have some shortcomings but overall I think there is more pros. If you use them you&apos;ll work closely with devs which could result in other interesting solutions:) Just remember to add them wisely - only in the elements you&apos;re using in tests:)&lt;/p&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>Importance of CI/CD and parallelisation in test automation</title><link>https://kodziak.com/blog/importance-of-ci-cd-and-parallelisation-in-test-automation/</link><guid isPermaLink="true">https://kodziak.com/blog/importance-of-ci-cd-and-parallelisation-in-test-automation/</guid><description>With growing test architecture, we are facing various problems. Execution time, flakiness, duplicate test cases etc. Tests are becoming hard to manage and we may start to feel like writing and maintaining them is meaningless.</description><pubDate>Sun, 31 Jan 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Nowadays, products change very often. We&apos;re create new versions of applications on daily basis. That means we need to know fast if everything works. To achieve this, we could run tests manually before every release or...?&lt;/p&gt;
&lt;p&gt;Let&apos;s automate this process.&lt;/p&gt;
&lt;h2&gt;How can CI/CD help with test automation?&lt;/h2&gt;
&lt;p&gt;Let&apos;s be honest. If we tell the developers &quot;you need to run the tests manually&quot;, they probably won&apos;t do it too often. Why? Because they are time-consuming. The execution usually takes more than an hour. Maybe it will work a few times, but I&apos;m pretty sure there will always be some kind of excuse. But that&apos;s life.&lt;/p&gt;
&lt;p&gt;Then we&apos;re coming to the problem that we don&apos;t want to merge untested code, ever. We want to run unit, integration, and end-to-end tests (of course, if we have all of them:)). In a convenient way of course. Without any extra work from the user.&lt;/p&gt;
&lt;p&gt;The worst we can do, is to make something dependant on us. Continuous processes require knowledge from the developers how to maintain the tests and that&apos;s very close to writing them. When we all work on one product, we&apos;re all responsible for its quality. And to achieve that, we should work closely, together. Who said that only testers could write E2E tests? Anyone from the development team can do it.&lt;/p&gt;
&lt;p&gt;Last but not least, in continuous processes we can block the deployment when a test suite fails. Then the author needs to fix the feature or maintain the tests, if changes affect them. Of course, deterministic tests are needed here, which we all know - is hard to reach.&lt;/p&gt;
&lt;h2&gt;Loooong time execution...&lt;/h2&gt;
&lt;p&gt;Yeah... The problem we all know. Many times I&apos;ve heard that tests takes one or two hours to finish.&lt;/p&gt;
&lt;p&gt;We should avoid that.&lt;/p&gt;
&lt;p&gt;Try to stick with 10-20 minutes to execute the core ones. To reach that, we can use parallelisation.&lt;/p&gt;
&lt;p&gt;We can distinguish two types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;run tests by groups,&lt;/li&gt;
&lt;li&gt;run multiple tests at a time.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Tests by groups&lt;/h3&gt;
&lt;p&gt;First, we should split our tests by groups/criticality. Recently I&apos;ve written an article about that: &lt;a href=&quot;https://kodziak.com/blog/what-is-smoke-sanity-regression-testing-how-to-ci-cd-with-them/&quot;&gt;What is smoke, sanity, regression testing? How to CI/CD with them.&lt;/a&gt; I&apos;ve split the tests by types. And with that, we could run the groups sequentially.&lt;/p&gt;
&lt;p&gt;For example, yours pipeline could looks like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;An approach like that, makes sure that the most important user flows are always gonna work. Then, on production environment we could check these less important ones. That&apos;s fine, until we&apos;re aware that something could be broken.&lt;/p&gt;
&lt;p&gt;You&apos;ll secure our time-to-market, while still checking everything you&apos;re supposed to.&lt;/p&gt;
&lt;h3&gt;Multiple tests at a time&lt;/h3&gt;
&lt;p&gt;Secondly, use parallel nodes. Basically, most of the tools are configured to run one test and then another. With a strong machine and properly configured tests you can run a few of them at a time.&lt;/p&gt;
&lt;p&gt;One of the out of the box tools which solves this problem, and makes the execution faster is &lt;a href=&quot;https://knapsackpro.com/&quot;&gt;Knapsack Pro&lt;/a&gt;. A very good tool to get the best execution time you can imagine.&lt;/p&gt;
&lt;h2&gt;Spread knowledge about tests&lt;/h2&gt;
&lt;p&gt;But what if a test suite fails? What happens then?&lt;/p&gt;
&lt;p&gt;There are two solutions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you can always monitor what happened and try to find a solution,&lt;/li&gt;
&lt;li&gt;you can make it easier for people to get the information about what happened,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And I really love the second option.&lt;/p&gt;
&lt;p&gt;I think everyone who works on software should be able to write, maintain, and fix the tests. You&apos;re working together to deliver the best product quality you can. That means you should avoid the stereotypical division between testers and developers. You&apos;re working together, as a development team.&lt;/p&gt;
&lt;p&gt;You can also implement automatically generated reports. Showing people, business, and other stakeholders what the tests cover, builds trust. And the trust in tests is what you need.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;You should deliver the best product quality you can in reasonable time. It&apos;s good when you can do it fast and with fine user experience (our internal users). People won&apos;t run tests manually, so you should automate it. That&apos;s why you could use continuous processes.&lt;/p&gt;
&lt;p&gt;Combining it with parallelisation, you&apos;ll secure the time-to-market.&lt;/p&gt;
&lt;p&gt;Spreading knowledge about tests makes more people feel responsible for them. If something fails - someone from the team will need to fix or maintain it. The more people work on tests, the better these tests are.&lt;/p&gt;
</content:encoded></item><item><title>Integration Testing in Web3: Connecting Smart Contracts with Frontend</title><link>https://kodziak.com/blog/integration-testing-web3-smart-contracts-frontend/</link><guid isPermaLink="true">https://kodziak.com/blog/integration-testing-web3-smart-contracts-frontend/</guid><description>Learn how to effectively integrate and test smart contracts with frontend applications in Web3 projects. Discover best practices, common pitfalls, and practical solutions.</description><pubDate>Sat, 26 Oct 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Ever deployed a smart contract only to find out it doesn&apos;t play nice with your frontend? Frustrating, right? You&apos;re not alone - a whopping 65% of Web3 projects face integration issues between smart contracts and frontends.&lt;/p&gt;
&lt;p&gt;Let&apos;s dive into how we can tackle this beast head-on! 🐉&lt;/p&gt;
&lt;h2&gt;The Challenge: Bridging Two Worlds&lt;/h2&gt;
&lt;p&gt;Imagine you&apos;re building a decentralized exchange (DEX). You&apos;ve got your ERC20 token contract and your exchange contract all set up on the blockchain. Now comes the tricky part - connecting these bad boys to your slick React frontend. How do you ensure everything works seamlessly? 🤔&lt;/p&gt;
&lt;h2&gt;Step 1: Set Up Your Testing Environment&lt;/h2&gt;
&lt;p&gt;First things first, we need a solid testing environment. Here&apos;s what you&apos;ll need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hardhat or Truffle for local blockchain simulation&lt;/li&gt;
&lt;li&gt;Ethers.js or Web3.js for interacting with smart contracts&lt;/li&gt;
&lt;li&gt;Jest or Mocha for running tests&lt;/li&gt;
&lt;li&gt;React Testing Library for frontend testing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&apos;s set up a basic test file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { ethers } from &quot;hardhat&quot;;
import { expect } from &quot;chai&quot;;
import { render, fireEvent, waitFor } from &quot;@testing-library/react&quot;;
import { Exchange } from &quot;../components/Exchange&quot;;

describe(&quot;DEX Integration&quot;, () =&amp;gt; {
  let tokenContract;
  let exchangeContract;

  beforeEach(async () =&amp;gt; {
    // Deploy contracts
    const Token = await ethers.getContractFactory(&quot;Token&quot;);
    tokenContract = await Token.deploy();

    const Exchange = await ethers.getContractFactory(&quot;Exchange&quot;);
    exchangeContract = await Exchange.deploy(tokenContract.address);

    // More setup...
  });

  it(&quot;should allow token swap&quot;, async () =&amp;gt; {
    // Test implementation
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 2: Mock Blockchain Interactions&lt;/h2&gt;
&lt;p&gt;One common pitfall is trying to test with real blockchain interactions. That&apos;s a no-no for integration tests. Instead, we&apos;ll mock these calls:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Don&apos;t do this:
const balance = await web3.eth.getBalance(userAddress);

// ✅ Do this instead:
jest.mock(&quot;web3&quot;);
web3.eth.getBalance.mockResolvedValue(&quot;1000000000000000000&quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Always explain your mocks and why you&apos;re using them. In this case, we&apos;re simulating a user with 1 ETH balance.&lt;/p&gt;
&lt;h2&gt;Step 3: Test Contract-Frontend Interaction&lt;/h2&gt;
&lt;p&gt;Now for the juicy part - testing how our frontend interacts with the smart contracts. Let&apos;s test a token swap:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;it(&quot;should allow token swap&quot;, async () =&amp;gt; {
  const { getByText, getByLabelText } = render(&amp;lt;Exchange 
    tokenContract={tokenContract}
    exchangeContract={exchangeContract}
  /&amp;gt;);

  // Simulate user input
  fireEvent.change(getByLabelText(&quot;Amount&quot;), { target: { value: &quot;10&quot; } });
  fireEvent.click(getByText(&quot;Swap&quot;));

  // Wait for the swap to complete
  await waitFor(() =&amp;gt; {
    expect(getByText(&quot;Swap Successful!&quot;)).toBeInTheDocument();
  });

  // Verify contract state
  const userBalance = await tokenContract.balanceOf(userAddress);
  expect(userBalance).to.equal(ethers.utils.parseEther(&quot;10&quot;));
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test simulates a user swapping 10 tokens and verifies both the UI update and the contract state change.&lt;/p&gt;
&lt;h2&gt;Common Pitfalls and How to Avoid Them&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Async Hell&lt;/strong&gt; 😈
Web3 is async by nature. Use &lt;code&gt;async/await&lt;/code&gt; and handle promises properly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gas Estimation&lt;/strong&gt; ⛽
Mock gas estimations in your tests to avoid unpredictable behavior.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Event Listening&lt;/strong&gt; 👂
Don&apos;t forget to test event emissions from your contracts and how your frontend handles them.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here&apos;s a quick example of testing event emission:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;it(&quot;should emit Transfer event&quot;, async () =&amp;gt; {
  await expect(tokenContract.transfer(recipient, amount))
    .to.emit(tokenContract, &quot;Transfer&quot;)
    .withArgs(sender, recipient, amount);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Best Practices for Web3 Integration Testing&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use a Local Blockchain&lt;/strong&gt; 🏠
Tools like Hardhat make it easy to simulate blockchain environments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Snapshot Testing&lt;/strong&gt; 📸
Great for catching unexpected changes in your UI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fuzz Testing&lt;/strong&gt; 🐝
Try random inputs to discover edge cases in your smart contracts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CI/CD Integration&lt;/strong&gt; 🔄
Automate your tests to run on every push or pull request.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Wrapping Up&lt;/h2&gt;
&lt;p&gt;Integration testing in Web3 is a unique challenge, but with the right approach, you can ensure your dApps are rock-solid. Remember, it&apos;s not just about testing your smart contracts or your frontend in isolation - it&apos;s about how they dance together! 💃🕺&lt;/p&gt;
&lt;p&gt;Got more questions about Web3 testing? Struggling with a specific integration issue? Don&apos;t sweat it! Head over to &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; where we&apos;re building a community of Web3 QA enthusiasts. Let&apos;s level up your testing game together! 🚀&lt;/p&gt;
&lt;p&gt;P.S. Drop a comment below if you want me to dive deeper into any specific aspect of Web3 integration testing. Your feedback shapes the content! 🙌&lt;/p&gt;
</content:encoded></item><item><title>Load testing types: load, stress, soak, spike. Examples in k6 load testing tool</title><link>https://kodziak.com/blog/load-testing-types-load-stress-soak-spike/</link><guid isPermaLink="true">https://kodziak.com/blog/load-testing-types-load-stress-soak-spike/</guid><description>Load testing is a well-known technique of software testing to make sure, that system we’re working on, behaves in a way, we’d like to.</description><pubDate>Fri, 12 Aug 2022 10:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Load testing is a well-known technique of software testing to make sure, that system we’re working on, behaves in a way, we’d like to. During day-to-day tasks, I started thinking if testing the product only from business perspective is enough. Well… No, so I started some research about it.&lt;/p&gt;
&lt;p&gt;I wanted to clarify for myself, what types give me what, as an outcome. What tool should I use, or environment? Do I need to set up something, or just use production? (yeah, jokes aside).&lt;/p&gt;
&lt;p&gt;I’ve tested &lt;code&gt;wrk&lt;/code&gt;, &lt;code&gt;jmeter&lt;/code&gt;, and &lt;code&gt;k6&lt;/code&gt;. At the end, the last one looks as the easiest and most configurable one for me. I’ve created a couple of sample scripts, to show you how to use that tool.&lt;/p&gt;
&lt;p&gt;In the next article, I’ll explain a bit more about environment, and flow how you can set up your load testing.&lt;/p&gt;
&lt;h2&gt;Types of load tests&lt;/h2&gt;
&lt;p&gt;We encounter four types of load tests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Load&lt;/li&gt;
&lt;li&gt;Stress&lt;/li&gt;
&lt;li&gt;Soak&lt;/li&gt;
&lt;li&gt;Spike&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of them is slightly different, and gives us possibility to check other scenarios/perform quite tests.&lt;/p&gt;
&lt;h2&gt;Load testing&lt;/h2&gt;
&lt;p&gt;Being sure, that the system is meeting the performance goals is one of the things, you should pay attention. This kind of test, is the one, which can provide you this answer.&lt;/p&gt;
&lt;p&gt;This type is concerned with assessing the current performance in terms of concurrent users or requests per second.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example code implementation&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { sleep } from &apos;k6&apos;;
import http from &apos;k6/http&apos;;

export const options = {
  stages: [
    { duration: &apos;5m&apos;, target: 100 },
    { duration: &apos;10m&apos;, target: 100 },
    { duration: &apos;5m&apos;, target: 0 },
  ],
  thresholds: {
    http_req_duration: [&apos;p(99)&amp;lt;250&apos;],
  },
};

export default function () {
  http.get(&apos;https://httpbin.test.loadimpact.com/&apos;);
  sleep(1); // Make sure, that each user cooldown between requests is 1s
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Stress testing&lt;/h2&gt;
&lt;p&gt;The purpose of this type of load test, is to verify the stability and reliability of the system, under extreme condition’s.&lt;/p&gt;
&lt;p&gt;Running this type of load test, will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;determine behavior of your system under extreme condition’s,&lt;/li&gt;
&lt;li&gt;determine maximum capacity in terms of users throughput,&lt;/li&gt;
&lt;li&gt;determine the breaking point of your system,&lt;/li&gt;
&lt;li&gt;tell you, if your system will recover without manual intervention after the stress test is over.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example code implementation&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { sleep } from &apos;k6&apos;;
import http from &apos;k6/http&apos;;

export const options = {
  stages: [
    { duration: &apos;2m&apos;, target: 100 },
    { duration: &apos;5m&apos;, target: 100 },
    { duration: &apos;2m&apos;, target: 200 },
    { duration: &apos;5m&apos;, target: 200 },
    { duration: &apos;2m&apos;, target: 300 },
    { duration: &apos;5m&apos;, target: 300 },
    { duration: &apos;2m&apos;, target: 400 },
    { duration: &apos;5m&apos;, target: 400 },
    { duration: &apos;10m&apos;, target: 0 },
  ],
};

export default function () {
  http.get(&apos;https://httpbin.test.loadimpact.com/&apos;);
  sleep(1);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Soak testing&lt;/h2&gt;
&lt;p&gt;The purpose of this type of load test, is to validate the system under long-time overload.&lt;/p&gt;
&lt;p&gt;Running this type of load test, will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;verify that your system doesn’t suffer from bugs or memory leaks,&lt;/li&gt;
&lt;li&gt;make sure, that your database works under high overload,&lt;/li&gt;
&lt;li&gt;make sure, that your logs works under high overload,&lt;/li&gt;
&lt;li&gt;make sure, that external services you depend on, doesn’t stop under high overload.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To run them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;determine the maximum number of users your system can handle,&lt;/li&gt;
&lt;li&gt;get the 80% of that value,&lt;/li&gt;
&lt;li&gt;run the test in three stages: ramp, stay and cooldown.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example code implementation&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { sleep } from &apos;k6&apos;;
import http from &apos;k6/http&apos;;

export const options = {
  stages: [
    { duration: &apos;5m&apos;, target: 400 },
    { duration: &apos;3h55m&apos;, target: 400 },
    { duration: &apos;5m&apos;, target: 0 },
  ],
  thresholds: {
    http_req_duration: [&apos;p(99)&amp;lt;250&apos;],
  },
};

export default function () {
  http.get(&apos;https://httpbin.test.loadimpact.com/&apos;);
  sleep(1); // Make sure, that each user cooldown between requests is 1s
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Spike testing&lt;/h2&gt;
&lt;p&gt;The purpose of this type of load test, is to validate the system under extreme increments and decrements in traffic over a very short time. The main purpose is to evaluate the behaviour of the system to determine recovery time.&lt;/p&gt;
&lt;p&gt;Running this type of load test, will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;determine how your system will perform under a sudden spikes of traffic,&lt;/li&gt;
&lt;li&gt;determine if your system will recover.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example code implementation&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { sleep } from &apos;k6&apos;;
import http from &apos;k6/http&apos;;

export const options = {
  stages: [
    { duration: &apos;10s&apos;, target: 100 },
    { duration: &apos;1m&apos;, target: 100 },
    { duration: &apos;10s&apos;, target: 1400 },
    { duration: &apos;3m&apos;, target: 1400 },
    { duration: &apos;10s&apos;, target: 100 },
    { duration: &apos;3m&apos;, target: 100 },
    { duration: &apos;10s&apos;, target: 0 },
  ],
  thresholds: {
    http_req_duration: [&apos;p(99)&amp;lt;250&apos;],
  },
};

export default function () {
  http.get(&apos;https://httpbin.test.loadimpact.com/&apos;);
  sleep(1); // Make sure, that each user cooldown between requests is 1s
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;Load testing is a powerful technique to make sure, that your system behaves as expected in various conditions. My personal feeling is that every project should consider them at some point. Getting more, and more clients can make flood the system, and produce terrible feedback, if it can’t handle them.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;k6&lt;/code&gt; seems to be great tool, to set up them fast, clearly with low learning curve.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=r-Jte8Y8zag&quot;&gt;Getting started with API Load Testing (Stress, Spike, Load, Soak)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.guru99.com/spike-testing.html&quot;&gt;What is Spike Testing in Software Testing? Learn With Example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>Separate or project repository to store tests? Which, why, and when?</title><link>https://kodziak.com/blog/separate-or-project-repository-to-store-tests-which-why-and-when/</link><guid isPermaLink="true">https://kodziak.com/blog/separate-or-project-repository-to-store-tests-which-why-and-when/</guid><description>While starting to work with end-to-end tests, one of the first questions is where to store them. Alongside source code or in separate repository? Two solutions, both slightly different. Each of the approaches has their pros and cons – but which to choose?</description><pubDate>Mon, 13 Dec 2021 20:00:00 GMT</pubDate><content:encoded>&lt;p&gt;While starting to work with end-to-end tests, one of the first questions is where to store them. Alongside source code or in separate repository? Two solutions, both slightly different. Each of the approaches has their pros and cons – but which to choose?&lt;/p&gt;
&lt;p&gt;In this short article, I&apos;ve tried to describe them both. They&apos;re different, and from your perspective you&apos;ve to choose which one to use, which isn&apos;t simple at all. I believe that this could help you a bit.&lt;/p&gt;
&lt;h2&gt;Project repository&lt;/h2&gt;
&lt;p&gt;Store tests alongside source code keeps everything in the same place. You&apos;ve both app-related and tests-related stuff like tasks, workflows etc. in the same spot. It causes, that the developers could execute everything much easier than searching some commands in another repository. It closes the gap between the developers and test engineers (SDET&apos;s). There aren&apos;t any barriers.&lt;/p&gt;
&lt;p&gt;When the tests fail, it would fail on the programmer branch, so it&apos;d be his job to maintain them. That&apos;s the mental shift when things are together. You wouldn&apos;t be responsible for bringing back the tests to love after every failure. Or find the person which going to fix them or the development is blocked.&lt;/p&gt;
&lt;p&gt;The point is, that storing everything in the same repository, there aren&apos;t any other “strange” place where some code checks the developer&apos;s job and makes it easier to maintain.&lt;/p&gt;
&lt;p&gt;What&apos;s more, when the newest feature change the application flow and breaks tests, you don&apos;t have problem with different versions of tests and app. They&apos;re synced because of the same repository. No concern with merges and only one thing which left would be to maintain them on the same branch as the feature is and push a complete working solution. The time when tests aren&apos;t compatible with the newest application version shouldn&apos;t exist.&lt;/p&gt;
&lt;h3&gt;Example structure&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;application-repository&amp;gt;/&amp;lt;root&amp;gt;/app
&amp;lt;application-repository&amp;gt;/&amp;lt;root&amp;gt;/tests
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Separate repository&lt;/h2&gt;
&lt;p&gt;When the test code is in “another” project, and it usually breaks — the developers probably won&apos;t care about it. It&apos;s going to be your job to maintain the tests and unstuck the blocker.&lt;/p&gt;
&lt;p&gt;Unfortunately, when the things are separated, it would reduce the collaboration between team members. If your organization have clear distinction between the developers and test engineers, a separate repository will widen that gap. One wouldn&apos;t work on each other solutions. That&apos;s really not a situation you should go. The most beneficial would be working together on both, the application code and tests, as a team.&lt;/p&gt;
&lt;p&gt;Imagine a situation. From the developer&apos;s perspective. You&apos;ve created a feature which breaks some of them and want&apos;s to merge it, fast. Obvious is, the tests would fail, so you&apos;ve to set up to another repository, maintain the tests and prepare request, or just merge the feature without properly working tests. It would create a gap because it&apos;s impossible to merge both, new versions of the code at the same time.&lt;/p&gt;
&lt;p&gt;In that scenario, each of the repositories going to have workflow according to its needs – which is good. It will separate the contexts, so the person which going to start working on one of the projects will have only things related to that. The application has tasks related to build and running the application, and in tests will contain jobs to set up the application under tests and execute them. But it has downsides too. It&apos;s just annoying to run the whole flow on local machines. You&apos;ll need to execute commands in different places, which bring up the complexity.&lt;/p&gt;
&lt;p&gt;Of course, I didn&apos;t say that only the test&apos;s repository has to contain tests – nah. The application should have their own. The developers should write unit tests alongside the source code and execute them in pipelines.&lt;/p&gt;
&lt;p&gt;Separating the repositories keeps more clean environment. Repositories contain only things it&apos;s concerned about. It&apos;s make easier to navigate on the daily basis. But there&apos;s a downside to this approach. You&apos;ll have more moving parts to your workflow, which makes things more complicated along the way. For example, with new developers, setup everything it&apos;s going to be a little more difficult in front of a situation, where everything is in one place.&lt;/p&gt;
&lt;h3&gt;Example structure&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;application-repository&amp;gt;/
&amp;lt;tests-repository&amp;gt;/
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;h3&gt;Project repository&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Increase ownership through the team,&lt;/li&gt;
&lt;li&gt;Closes the gap between the developers and test engineers,&lt;/li&gt;
&lt;li&gt;No problem with merging, you&apos;ll always have synced versions between tests and application,&lt;/li&gt;
&lt;li&gt;Everything app and tests related going to be in the same place.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Separate repository&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Decrease ownership through the team,&lt;/li&gt;
&lt;li&gt;Widen the gap between the developers and test engineers,&lt;/li&gt;
&lt;li&gt;Could be a situation where tests aren&apos;t working on newest application version,&lt;/li&gt;
&lt;li&gt;Cleaner environment, only things concerned about are in the repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Reading the article and points above, it seems like a single repository is a straight winner. But it&apos;s just how it works for me, most of the time. It doesn&apos;t mean, that it&apos;s the best solution for your organization. It always depends – on your project architecture, company structure, how many people you have and how you&apos;re working as a test engineers.&lt;/p&gt;
&lt;p&gt;The best would be to talk to your teammates and decide as a team which could work better for you. Work together on that topic. I assumed that you have in-house test engineers. If not, then, probably you should choose a separate repository for the tests.&lt;/p&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>Set up special Github readme! Examples included!</title><link>https://kodziak.com/blog/set-up-special-github-readme/</link><guid isPermaLink="true">https://kodziak.com/blog/set-up-special-github-readme/</guid><description>Some time ago I hit an article, that Github added a special type of repository, the ones you see above (we&apos;ll make it better), where we can write something about us. I think, that&apos;s a great idea to show, what exactly I&apos;m doing, and maybe... it could give me some movement to my initiatives?</description><pubDate>Thu, 17 Sep 2020 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Some time ago I hit an article, that Github added a special type of repository, the ones you see above (we&apos;ll make it better), where we can write something about us. I think, that&apos;s a great idea to show, what exactly I&apos;m doing, and maybe... it could give me some movement to my initiatives?&lt;/p&gt;
&lt;p&gt;But there&apos;s one problem. I don&apos;t like writing about me, I just... don&apos;t. I can&apos;t do this right (but I&apos;m writing a blog, huh).&lt;/p&gt;
&lt;p&gt;The good one is that Github gave us a basic template, where we just can edit some entries and voila, we&apos;ll have something similar as I have.&lt;/p&gt;
&lt;p&gt;If you&apos;re curious how to add this to your Github profile - read the whole article.&lt;/p&gt;
&lt;h2&gt;How to create your own?&lt;/h2&gt;
&lt;p&gt;You need to create a repository, but it&apos;s a special type. It has to be named as your GitHub account. So just go to &lt;a href=&quot;https://github.com/new&quot;&gt;https://github.com/new&lt;/a&gt;, same as you&apos;ll have to create a normal repository, and when you&apos;ll type the name of your account (in my case it&apos;s &lt;code&gt;kodziak&lt;/code&gt;), you&apos;ll be greeted with a message telling you about this special repository.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Highly recommend setting up this repository as a &lt;code&gt;private&lt;/code&gt; to avoid showing a messy/broken page in time you&apos;ll be working on it.&lt;/p&gt;
&lt;p&gt;Also, you can initialize base &lt;code&gt;README.md&lt;/code&gt; file, which will automatically appear in your profile.&lt;/p&gt;
&lt;p&gt;And voila - you have your own page.&lt;/p&gt;
&lt;h2&gt;Let&apos;s make it awesome&lt;/h2&gt;
&lt;p&gt;Doing research, I found some nice (nicer than mine, huh) showing pages. So I thought, why not make me more interesting?&lt;/p&gt;
&lt;p&gt;I solicited my page into categories. As you may know, I&apos;m also a podcaster (I hope, you know if not, shame on you - I&apos;m kidding), so I&apos;ll go with categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Who am I?&lt;/li&gt;
&lt;li&gt;My core actions (like blog, podcast)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And at the footer - some of my social media, where you can connect and write to me (feel free, I&apos;m always answering!).&lt;/p&gt;
&lt;h3&gt;Assumptions I go with&lt;/h3&gt;
&lt;p&gt;I like emojis, so I&apos;ll go with like every header for a specific category that will contain one. I think it&apos;s the way we can add some colors and fun to this text.&lt;/p&gt;
&lt;p&gt;But conversely to emojis, I like simplicity, so I thought without adding so many colors, images, gifs, etc, because it just not my style. All the time, I&apos;m trying to keep it simple, to show this nice guy/woman who will come to my profile, as many pieces of information as he/she can get in just a few seconds. Not distracting him/her by jumping ducks.&lt;/p&gt;
&lt;p&gt;Another rule I think you should stick is to make it short. No one wants to read long, boring texts (like this one). I&apos;m a fan of short tips and tricks, wherein seconds I can get what I wanted - so I&apos;m tried to keep my page in this style.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Make it fun, simple, and short. But make it. I could help you.&lt;/p&gt;
&lt;p&gt;I hope, this article gave you knowledge on how to set up this and inspiration how can you improve (setup?) your page. If yes - feel free to write to me with a link, I&apos;ll put it there!&lt;/p&gt;
&lt;p&gt;Feel free to write to me with any topic 😇&lt;/p&gt;
&lt;p&gt;Have a nice day!&lt;/p&gt;
&lt;p&gt;In case you need inspiration, there are some interesting ones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/WaylonWalker/WaylonWalker&quot;&gt;https://github.com/WaylonWalker/WaylonWalker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/stephenajulu/stephenajulu&quot;&gt;https://github.com/stephenajulu/stephenajulu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/kodziak/kodziak&quot;&gt;https://github.com/kodziak/kodziak&lt;/a&gt; (it&apos;s mine)&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>Six things you should consider while designing a test architecture</title><link>https://kodziak.com/blog/six-things-you-should-consider-while-designing-a-test-architecture/</link><guid isPermaLink="true">https://kodziak.com/blog/six-things-you-should-consider-while-designing-a-test-architecture/</guid><description>The beginning of automated tests in a project is easy and difficult at the same time. You can start smoothly, using base architecture, simple tests, etc - and it&apos;s gonna work! But... With growing architecture, solutions you&apos;ll take could be very hard to develop in the future. That&apos;s why, you should consider a few things, before the start. I want to show you the problems and solutions do they solve.</description><pubDate>Tue, 23 Feb 2021 10:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The beginning of automated tests in a project is easy and difficult at the same time. You can start smoothly, using base architecture, simple tests, etc - and it&apos;s gonna work! But... With growing architecture, solutions you&apos;ll take could be very hard to develop in the future.&lt;/p&gt;
&lt;p&gt;That&apos;s why, you should consider a few things, before the start. I want to show you the problems and solutions do they solve.&lt;/p&gt;
&lt;h2&gt;Page Object Model&lt;/h2&gt;
&lt;p&gt;POM - Page Object Model is a design pattern that is commonly used in test automation for avoiding code duplication and improve test maintenance.&lt;/p&gt;
&lt;p&gt;This model contains classes that represent web pages. You break down each page into a corresponded page class. This class contains locators (selectors) to web page elements and methods that perform actions on them.&lt;/p&gt;
&lt;p&gt;This fills the most common actions you&apos;ll be doing in test automation - find the element, fill the value, click the button. For small scripts, you can store selectors in the tests, but with growing suites, you&apos;ll face many duplications - that&apos;s bad, you don&apos;t want them. If one of the used selectors gonna change, you&apos;ll need to update every place, you&apos;ve used it.&lt;/p&gt;
&lt;p&gt;And... POM is the solution. You&apos;ll create a separate class that all of the tests gonna use. Then, if any of the selectors change, you&apos;ll only have to update one place. It&apos;s faster for the person which updates it.&lt;/p&gt;
&lt;p&gt;But... There is another model of creating an architecture for automation tests. It&apos;s called App Actions. I&apos;ve never tested it, so I can&apos;t recommend it, but here&apos;s a nice article about it - &lt;a href=&quot;https://www.cypress.io/blog/2019/01/03/stop-using-page-objects-and-start-using-app-actions/&quot;&gt;click!&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Logging&lt;/h2&gt;
&lt;p&gt;You should use a logging system to give the user (developer, or tester) enough information about what&apos;s happened in the tests while executing in a relatively short time. It&apos;s most possible, that you&apos;ll run your tests through a remote machine. If they fail, you need to know fast what&apos;s happened. Troubleshoot or reproduce failed tests with a stack trace and the latest assertion message only will be very hard.&lt;/p&gt;
&lt;p&gt;That&apos;s why you should design a logging system.&lt;/p&gt;
&lt;p&gt;A well-designed strategy will show the user step by step, what&apos;s happened in the test. In the project that I&apos;ve worked on, we created a three-step strategy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;begin,&lt;/li&gt;
&lt;li&gt;info,&lt;/li&gt;
&lt;li&gt;end,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To do this quickly, we&apos;ve used decorators (TypeScript only).&lt;/p&gt;
&lt;p&gt;For example (code base on puppeteer):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@logger
function getText(selector) {
	return page.$eval(selector, (el) =&amp;gt; el.textContent);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Result with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[BEGIN] - getText from: #email
[INFO] - getText result: sampleemail@gmail.com
[END] - getText from: #email
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The assumption was simple. We want to know when the method starts, what&apos;s the result and when ends. We&apos;ve used a method name and parameters as a recognizer. That comes out with well-structured logs, which helps us to know exactly what happened in test execution.&lt;/p&gt;
&lt;p&gt;Also, you can use these logs in your reporting system, which is described below.&lt;/p&gt;
&lt;p&gt;Another good idea to mention is to write custom, detailed assertion messages. For example,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Expect: 5, Received: 8
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&apos;s saying not much. Without the context and knowledge of what the test is checking, it&apos;s hard to assume what&apos;s happened. You&apos;ll need to check it manually. But...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;We expect 5 elements on the listing, got 8.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&apos;s easy to read and clearly saying what&apos;s happened. From the message, you can easily assume where&apos;s the problem.&lt;/p&gt;
&lt;p&gt;Also, there are two more areas, where detailed messages could be helpful:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;timeout exceptions - ex. internet connections problem,&lt;/li&gt;
&lt;li&gt;architecture exceptions - ex. DB connection, auth connection problem.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I believe, that having a proper logging system could make your work easier and speed up the troubleshooting process.&lt;/p&gt;
&lt;h2&gt;Test Data&lt;/h2&gt;
&lt;p&gt;Most common action in your tests gonna be to fill the value within the data. But... You need to have, or generate it. It&apos;s one of the most time-consuming actions, but necessary.&lt;/p&gt;
&lt;p&gt;Let&apos;s split the data into two types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;static data - the one you store in database/repository/somewhere,&lt;/li&gt;
&lt;li&gt;dynamic data - the one you generate using tools like a faker, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using class patterns you can design a system that handles the data for you. Connections to a database or dynamically creating sensitive data (ex. from &lt;code&gt;faker.js&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;Parallel Executions&lt;/h2&gt;
&lt;p&gt;Parallelization is an automated process that automatically launches your actions simultaneously. The goal is to save execution time by distributing tests across available resources.&lt;/p&gt;
&lt;p&gt;Consider a situation. You have a big database. Execution time takes 50 minutes to complete. You have 50 tests, where one approximately takes 1 minute. Tests are isolated (if not, you need to work on them). Using 5 parallel executions, you can reduce the total testing time to 10 minutes.&lt;/p&gt;
&lt;p&gt;Fast, reliable tests are key to a stable product.&lt;/p&gt;
&lt;p&gt;One, the interesting out-of-the-box solution is &lt;a href=&quot;https://knapsackpro.com/&quot;&gt;Knapsack Pro&lt;/a&gt;. It helps run your tests in a parallel efficient way.&lt;/p&gt;
&lt;h2&gt;Deployment Pipeline&lt;/h2&gt;
&lt;p&gt;A deployment pipeline is a process, where you take the code from version control and make it available for the users in an automated way. The team, which works on a project, needs an efficient way to build, test, and deploy their work to the production environment. In old fashion way, this was a manual process, where there were few deployments per week, now it&apos;s a few per day/hour. A set of automated tools doing it for us.&lt;/p&gt;
&lt;p&gt;Imagine a problem. You have 50 tests and execution takes 50 minutes (without parallel executions). To test the fresh version of the code, the developers need to build an application locally and run the tests against it. And okay, the tests found an issue, so the user fixes the code and does it again. Hours and nervousness growing. I&apos;m pretty sure, that after a few rounds they&apos;re not gonna use the tests. You don&apos;t want this.&lt;/p&gt;
&lt;p&gt;The solution is to use an automated deployment pipeline. It&apos;s designed especially for cases like this.&lt;/p&gt;
&lt;p&gt;Combining it with parallel executions, you will create an efficient, fast strategy, which gonna defend your production with the tests. Even better, if failed tests block the deployment. You&apos;ll never push broken code to the real users. 🥳&lt;/p&gt;
&lt;h2&gt;Reports&lt;/h2&gt;
&lt;p&gt;Reporting is about documenting the process of test execution. They should combine a summary for the management and stakeholders. Also, should be detailed to give the developers feedback. Especially, when something fails.&lt;/p&gt;
&lt;p&gt;Consider a failed execution. Tests are running on a remote machine, and somehow, you need to know what exactly happened. Why they failed and what&apos;s broken. Access to plain logs could be painful in searching this one failed test. A well-created report should cover that.&lt;/p&gt;
&lt;p&gt;Each report could be different, but in my opinion, there are a few must-have metrics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;machine/environment name,&lt;/li&gt;
&lt;li&gt;total number of running tests,&lt;/li&gt;
&lt;li&gt;duration,&lt;/li&gt;
&lt;li&gt;list of all test cases with logs (steps from logging system) in toggle,&lt;/li&gt;
&lt;li&gt;test result (for every test case).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Have I mentioned failed test executions and it&apos;s crucial to know what happened? 🥳 Constantly looking at a deployment pipeline dashboard or searching in logs isn&apos;t that efficient. A well-written report, mixed with the slack notification can speed up this process much.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I&apos;ve described six topics, which are really nice to consider in every mature test automation project. They solve problems, which you&apos;ll encounter on daily basis. By doing some coding and research, you&apos;ll easier your work and make the architecture expandable. Using a few hacks, you&apos;ll speed up your troubleshooting process and with automatically generated reports - you&apos;ll be as transparent as possible with your tests.&lt;/p&gt;
&lt;p&gt;I believe, that this knowledge will help you at the beginning of your journey.&lt;/p&gt;
&lt;p&gt;What&apos;s also good to consider:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;base architecture - pattern to re-use base methods, create browsers,&lt;/li&gt;
&lt;li&gt;video recordings - record whole test session,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>Testing NFT Smart Contracts: Common Edge Cases You&apos;re Missing</title><link>https://kodziak.com/blog/testing-nft-smart-contracts-common-edge-cases/</link><guid isPermaLink="true">https://kodziak.com/blog/testing-nft-smart-contracts-common-edge-cases/</guid><description>Discover crucial edge cases in NFT smart contract testing that are often overlooked, with practical examples and solutions for robust contract security.</description><pubDate>Tue, 26 Nov 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;If you&apos;re building in this space, you know how critical it is to get your contracts right. But here&apos;s the kicker - a whopping 80% of NFT projects miss crucial edge cases in their testing. Yikes! 😱&lt;/p&gt;
&lt;p&gt;Let&apos;s fix that, shall we? We&apos;ll explore some common pitfalls and how to avoid them. Ready to level up your NFT contract game? Let&apos;s go!&lt;/p&gt;
&lt;h2&gt;1. The Sneaky Approve and Transfer 🕵️‍♂️&lt;/h2&gt;
&lt;p&gt;One of the most overlooked scenarios is when a user approves a transfer, but the transfer doesn&apos;t happen immediately. Here&apos;s what can go wrong:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Don&apos;t do this:
function testApproveAndTransfer() {
  // Approve
  // Assert approval
  // Transfer
  // Assert transfer
}

// ✅ Do this instead:
function testApproveAndTransferWithDelay() {
  // Approve
  // Assert approval
  // Simulate time passing
  // Transfer
  // Assert transfer
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why does this matter? In real-world scenarios, there might be a delay between approval and transfer. By simulating this delay, you can catch potential vulnerabilities that only surface when transactions don&apos;t occur back-to-back.&lt;/p&gt;
&lt;h2&gt;2. The Greedy Minter 🤑&lt;/h2&gt;
&lt;p&gt;Ever thought about what happens if someone tries to mint more NFTs than allowed? Many don&apos;t, but you should!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Incomplete test:
function testMint() {
  // Mint allowed amount
  // Assert success
}

// ✅ Comprehensive test:
function testMintWithEdgeCases() {
  // Mint allowed amount
  // Assert success
  // Try to mint one more
  // Assert failure with correct error message
  // Try to mint max uint256
  // Assert failure with correct error message
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test covers not just the happy path, but also attempts to break the system. It&apos;s crucial to ensure your contract handles these edge cases gracefully.&lt;/p&gt;
&lt;h2&gt;3. The Royalty Roundabout 💰&lt;/h2&gt;
&lt;p&gt;Royalties are a big deal in the NFT world, but testing them can be tricky. Here&apos;s an often-missed scenario:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Basic royalty test:
function testRoyalties() {
  // Set royalties
  // Sell NFT
  // Check royalty payment
}

// ✅ Comprehensive royalty test:
function testRoyaltiesWithEdgeCases() {
  // Set royalties
  // Sell NFT
  // Check royalty payment
  // Change royalty recipient
  // Sell NFT again
  // Check new recipient gets payment
  // Try to set royalties &amp;gt; 100%
  // Assert failure
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This expanded test covers changing royalty recipients and attempts to set invalid royalty percentages - crucial for maintaining fairness and preventing exploits.&lt;/p&gt;
&lt;h2&gt;4. The Metadata Mayhem 🎭&lt;/h2&gt;
&lt;p&gt;Metadata is the soul of an NFT, but it&apos;s often undertested. Let&apos;s change that:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Simple metadata test:
function testMetadata() {
  // Set tokenURI
  // Assert tokenURI
}

// ✅ Robust metadata test:
function testMetadataEdgeCases() {
  // Set valid tokenURI
  // Assert tokenURI
  // Set empty tokenURI
  // Assert failure or default behavior
  // Set extremely long tokenURI
  // Check gas costs and potential DOS vectors
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This comprehensive test ensures your metadata handling is bulletproof, even in extreme scenarios.&lt;/p&gt;
&lt;h2&gt;5. The Ownership Odyssey 🚀&lt;/h2&gt;
&lt;p&gt;Ownership transfers are common, but are you testing all scenarios?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ❌ Basic ownership test:
function testOwnership() {
  // Transfer ownership
  // Assert new owner
}

// ✅ Thorough ownership test:
function testOwnershipScenarios() {
  // Transfer ownership
  // Assert new owner
  // Try to transfer ownership as old owner
  // Assert failure
  // Transfer to zero address
  // Assert failure
  // Renounce ownership
  // Assert owner is zero address
  // Try to transfer after renouncing
  // Assert failure
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test suite covers various ownership scenarios, including edge cases that could lead to locked contracts or loss of control.&lt;/p&gt;
&lt;h2&gt;Wrapping Up 🎁&lt;/h2&gt;
&lt;p&gt;Testing NFT smart contracts is no walk in the park, but catching these edge cases can save you from major headaches (and potential losses) down the line. Remember, in the world of blockchain, there are no take-backsies!&lt;/p&gt;
&lt;p&gt;By implementing these more comprehensive tests, you&apos;re not just ticking boxes - you&apos;re building a fortress around your NFTs. And in this wild west of Web3, that&apos;s exactly what you need.&lt;/p&gt;
&lt;p&gt;Feeling overwhelmed? Don&apos;t sweat it! This stuff is complex, and it&apos;s okay to need a hand. If you want to dive deeper into Web3 testing strategies or need expert help in securing your NFT projects, head over to &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt;. We&apos;re here to help you build rock-solid NFT contracts that stand the test of time (and hackers).&lt;/p&gt;
&lt;p&gt;Stay curious, keep testing, and let&apos;s make the NFT space safer for everyone! 🛡️💎&lt;/p&gt;
</content:encoded></item><item><title>Testing smart contract upgrades: a complete testing strategy</title><link>https://kodziak.com/blog/testing-smart-contract-upgrades-complete-strategy/</link><guid isPermaLink="true">https://kodziak.com/blog/testing-smart-contract-upgrades-complete-strategy/</guid><description>Learn how to effectively test smart contract upgrades with a comprehensive strategy, including practical examples and best practices for Web3 developers.</description><pubDate>Sun, 10 Nov 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Ready to level up your smart contract upgrade testing game? You&apos;re in the right place!&lt;/p&gt;
&lt;p&gt;Did you know that over 60% of smart contract vulnerabilities are introduced during upgrades? 😱 That&apos;s a scary number, but don&apos;t worry - I&apos;ve got your back. Let&apos;s dive into a complete testing strategy that&apos;ll help you sleep better at night (and keep your users&apos; funds safe).&lt;/p&gt;
&lt;h2&gt;Why is testing upgrades so crucial? 🤔&lt;/h2&gt;
&lt;p&gt;Imagine this: You&apos;ve just pushed an upgrade to your DeFi protocol, and suddenly... 💥 BOOM! Users can&apos;t withdraw their funds, or worse, someone&apos;s exploiting a new vulnerability. Not cool, right?&lt;/p&gt;
&lt;p&gt;That&apos;s why we need a rock-solid testing strategy for upgrades. Let&apos;s break it down step by step.&lt;/p&gt;
&lt;h2&gt;1. Baseline Testing 📊&lt;/h2&gt;
&lt;p&gt;Before you even think about upgrading, make sure your current contract is thoroughly tested. This means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit tests for each function&lt;/li&gt;
&lt;li&gt;Integration tests for complex interactions&lt;/li&gt;
&lt;li&gt;Fuzz testing to catch edge cases&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&apos;s a quick example of a baseline test:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ✅ Do this:
describe(&quot;TokenVault&quot;, function() {
  it(&quot;should allow deposits&quot;, async function() {
    const [owner, user] = await ethers.getSigners();
    const TokenVault = await ethers.getContractFactory(&quot;TokenVault&quot;);
    const vault = await TokenVault.deploy();
    await vault.deposit({ value: ethers.utils.parseEther(&quot;1&quot;) });
    expect(await vault.balanceOf(owner.address)).to.equal(ethers.utils.parseEther(&quot;1&quot;));
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Always explain your tests and what they&apos;re checking. This helps your team understand the coverage and importance of each test.&lt;/p&gt;
&lt;h2&gt;2. Upgrade Simulation 🔄&lt;/h2&gt;
&lt;p&gt;Before deploying to mainnet, simulate the upgrade process in a test environment. This includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deploying the new contract&lt;/li&gt;
&lt;li&gt;Migrating state (if necessary)&lt;/li&gt;
&lt;li&gt;Verifying that all functions work as expected post-upgrade&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&apos;s how you might test an upgrade:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ✅ Do this:
it(&quot;should maintain user balances after upgrade&quot;, async function() {
  const TokenVaultV1 = await ethers.getContractFactory(&quot;TokenVaultV1&quot;);
  const vaultV1 = await upgrades.deployProxy(TokenVaultV1);
  await vaultV1.deposit({ value: ethers.utils.parseEther(&quot;1&quot;) });

  const TokenVaultV2 = await ethers.getContractFactory(&quot;TokenVaultV2&quot;);
  const vaultV2 = await upgrades.upgradeProxy(vaultV1.address, TokenVaultV2);

  expect(await vaultV2.balanceOf(owner.address)).to.equal(ethers.utils.parseEther(&quot;1&quot;));
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This test ensures that user balances are preserved during the upgrade process. Always check critical state variables and functionality!&lt;/p&gt;
&lt;h2&gt;3. Backwards Compatibility Checks 🔙&lt;/h2&gt;
&lt;p&gt;Upgrades shouldn&apos;t break existing functionality. Test that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Old function calls still work&lt;/li&gt;
&lt;li&gt;Events are emitted correctly&lt;/li&gt;
&lt;li&gt;External contract interactions remain intact&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;4. New Feature Testing 🆕&lt;/h2&gt;
&lt;p&gt;For any new features introduced in the upgrade:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write comprehensive unit tests&lt;/li&gt;
&lt;li&gt;Perform integration tests with existing functions&lt;/li&gt;
&lt;li&gt;Fuzz test new inputs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;5. Gas Optimization Verification ⛽&lt;/h2&gt;
&lt;p&gt;Upgrades can sometimes introduce unexpected gas costs. Always check that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Function gas costs haven&apos;t increased significantly&lt;/li&gt;
&lt;li&gt;New functions are gas-efficient&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&apos;s a simple gas test:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// ✅ Do this:
it(&quot;should not increase gas costs significantly&quot;, async function() {
  const tx = await vaultV2.deposit({ value: ethers.utils.parseEther(&quot;1&quot;) });
  const receipt = await tx.wait();
  expect(receipt.gasUsed).to.be.below(100000); // Adjust based on your expectations
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;6. Security Audits 🔒&lt;/h2&gt;
&lt;p&gt;Don&apos;t skip this step! After your internal testing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Conduct a thorough security audit&lt;/li&gt;
&lt;li&gt;Use automated tools like Slither or Mythril&lt;/li&gt;
&lt;li&gt;Consider a manual audit by security experts&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;7. Testnet Deployment 🌐&lt;/h2&gt;
&lt;p&gt;Before hitting mainnet:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deploy to testnet&lt;/li&gt;
&lt;li&gt;Run all tests in a live environment&lt;/li&gt;
&lt;li&gt;Encourage community testing and bug bounties&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;8. Upgrade Rehearsal 🎭&lt;/h2&gt;
&lt;p&gt;Practice makes perfect:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Simulate the entire upgrade process&lt;/li&gt;
&lt;li&gt;Time each step&lt;/li&gt;
&lt;li&gt;Prepare a rollback plan&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;9. Post-Upgrade Verification ✅&lt;/h2&gt;
&lt;p&gt;After the upgrade:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Run all tests again on the upgraded contract&lt;/li&gt;
&lt;li&gt;Monitor for any unusual activity&lt;/li&gt;
&lt;li&gt;Be ready to respond to user reports&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember, testing is not a one-time thing. It&apos;s an ongoing process that continues even after the upgrade is live.&lt;/p&gt;
&lt;h2&gt;Wrapping Up 🎁&lt;/h2&gt;
&lt;p&gt;Testing smart contract upgrades is no joke. It requires a systematic approach, attention to detail, and a healthy dose of paranoia. But with this strategy, you&apos;re well-equipped to handle upgrades like a pro.&lt;/p&gt;
&lt;p&gt;Got questions about implementing this strategy? Need help setting up your testing pipeline? I&apos;m here to help! Check out &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; for more resources on Web3 testing and quality assurance. Let&apos;s make the blockchain a safer place, one test at a time! 💪&lt;/p&gt;
&lt;p&gt;Happy testing, and may your upgrades always be smooth! 🚀&lt;/p&gt;
</content:encoded></item><item><title>Web2 vs Web3 Testing: Key Differences That Will Surprise You</title><link>https://kodziak.com/blog/web2-vs-web3-testing-key-differences/</link><guid isPermaLink="true">https://kodziak.com/blog/web2-vs-web3-testing-key-differences/</guid><description>Discover crucial differences between Web2 and Web3 testing approaches, with practical examples and solutions for common challenges.</description><pubDate>Sat, 26 Oct 2024 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Hey there, fellow testers and Web3 enthusiasts! 👋
Today, we&apos;re diving deep into the world of Web2 vs Web3 testing. Buckle up, &apos;cause it&apos;s gonna be a wild ride! 🎢&lt;/p&gt;
&lt;h2&gt;The Basics: Web2 vs Web3&lt;/h2&gt;
&lt;p&gt;Before we jump into the testing differences, let&apos;s quickly recap what Web2 and Web3 actually are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Web2&lt;/strong&gt;: The internet we know and love (or sometimes hate 😅). Centralized, controlled by big tech companies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Web3&lt;/strong&gt;: The new kid on the block. Decentralized, powered by blockchain, and giving power back to the users.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Key Differences in Testing Approaches&lt;/h2&gt;
&lt;h3&gt;1. Environment Setup&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
Pretty straightforward. You set up your local environment, maybe a staging server, and you&apos;re good to go.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
Oh boy, here&apos;s where things get spicy! 🌶️ You need to set up a local blockchain, deal with test networks (testnets), and sometimes even fork the mainnet. It&apos;s like cooking a gourmet meal instead of microwaving a TV dinner.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Web3 local environment setup using Hardhat
require(&apos;@nomiclabs/hardhat-waffle&apos;);

module.exports = {
  solidity: &apos;0.8.0&apos;,
  networks: {
    hardhat: {
      forking: {
        url: &apos;https://mainnet.infura.io/v3/YOUR-PROJECT-ID&apos;,
      },
    },
  },
};
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;2. State Management&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
State is typically managed on the server or in the browser. Resetting state is as easy as clearing a database or local storage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
State lives on the blockchain, my friend! Resetting it means redeploying smart contracts or resetting your local blockchain. It&apos;s like trying to erase your embarrassing high school photos – not impossible, but definitely more complicated. 😅&lt;/p&gt;
&lt;h3&gt;3. Handling Asynchronous Operations&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
Async operations are usually related to API calls or database queries.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
Welcome to the world of blockchain confirmations! Every transaction needs to be mined and confirmed. It&apos;s like waiting for your crush to text back – sometimes quick, sometimes painfully slow.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Web3 transaction wait
const tx = await contract.someFunction();
await tx.wait(2); // Wait for 2 block confirmations
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;4. Security Testing&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
Focus on things like XSS, CSRF, SQL injection.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
Enter the realm of smart contract vulnerabilities! Reentrancy attacks, front-running, and gas optimization become your new best friends (or worst enemies). It&apos;s like playing chess, but every piece is trying to steal your ETH.&lt;/p&gt;
&lt;h3&gt;5. Performance Testing&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
Load testing, stress testing, you know the drill.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
Gas optimization becomes crucial. You&apos;re not just testing how many users your app can handle, but how efficiently it uses blockchain resources. It&apos;s like trying to fit your entire wardrobe into a tiny suitcase for a weekend trip.&lt;/p&gt;
&lt;h3&gt;6. User Authentication&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Web2&lt;/strong&gt;:
Username/password, OAuth, maybe some 2FA if you&apos;re fancy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web3&lt;/strong&gt;:
Welcome to the world of wallets and signatures! Users sign transactions with their private keys. It&apos;s like having a unique, cryptographic fingerprint for every action.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Web3 authentication example
const message = &apos;Login to MyAwesomeWeb3App&apos;;
const signature = await signer.signMessage(message);
// Verify signature on the backend
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Common Challenges and Solutions&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deterministic Testing&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Challenge: Blockchain&apos;s inherent randomness makes repeatable tests tricky.&lt;/li&gt;
&lt;li&gt;Solution: Use controlled environments and seed your RNG for deterministic results.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Long-running Tests&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Challenge: Waiting for blockchain confirmations can make tests slow.&lt;/li&gt;
&lt;li&gt;Solution: Use time-travel features in local blockchains to speed things up.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gas Costs&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Challenge: Tests can get expensive on public testnets.&lt;/li&gt;
&lt;li&gt;Solution: Use local blockchains or forked mainnet for most tests.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complex State&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Challenge: Blockchain state can be complex and interdependent.&lt;/li&gt;
&lt;li&gt;Solution: Use snapshots to quickly reset to a known state between tests.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Testing in Web3 is like Web2 testing on steroids. 💪 It&apos;s more complex, more challenging, but also more exciting! As the Web3 space evolves, so do our testing methodologies. Stay curious, keep learning, and most importantly, have fun with it!&lt;/p&gt;
&lt;p&gt;Ready to level up your Web3 testing game? Check out &lt;a href=&quot;https://web3qa.xyz&quot;&gt;web3qa.xyz&lt;/a&gt; for more in-depth guides, tools, and best practices. Let&apos;s make the decentralized world a better-tested place, one smart contract at a time! 🚀&lt;/p&gt;
</content:encoded></item><item><title>What is screenshot, UI, API, and performance testing?</title><link>https://kodziak.com/blog/what-is-screenshot-ui-api-performance-testing/</link><guid isPermaLink="true">https://kodziak.com/blog/what-is-screenshot-ui-api-performance-testing/</guid><description>Building a product, we face the moment that we need more types of tests. Screenshot, UI, API, or Performance? There are many of them and every one is designed for other purposes.</description><pubDate>Mon, 28 Dec 2020 14:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Building a product, we face the moment that we need more types of tests. Screenshot, UI, API, or Performance? There are many of them and every one is designed for other purposes.&lt;/p&gt;
&lt;p&gt;Every type is different, and can help us with other things. I think, most of them should occur in mature projects, but for sure - you should know all of them.&lt;/p&gt;
&lt;p&gt;So... What is...?&lt;/p&gt;
&lt;h2&gt;Screenshot testing&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;What is screenshot testing?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Screenshot testing is a technique used by end-to-end testing which captures a screenshot from a given URL and then compares the result with an expected image.&lt;/p&gt;
&lt;p&gt;The most common usage of this type of test is to check if the user interface (UI) isn&apos;t broken and the page has been rendered properly.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why you should do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Coming from old internet explorer to newest version of chrome. Using mobile and desktop in various OS. It&apos;s hard to check everywhere if our application renders properly. Not to mention a problem, where the developer will break something accidentally. A simple change could destroy our design.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;How you can do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;You can capture bulk screenshots through different desktop and mobile devices running in the various OS. All of them, you can compare with an expected image (snapshot). If the test will pass, you can deploy a new version of the application, otherwise, with the designed flow, you can ask a manager or designer to accept or reject changes. A simple diagram, I&apos;ve prepared below.&lt;/p&gt;
&lt;h3&gt;Deployment diagram&lt;/h3&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But there is one thing you need to remember. You need to work closely with designers and developers. It&apos;s their job to accept changes in UI or revert them to the developer if something&apos;s broken.&lt;/p&gt;
&lt;h3&gt;Popular tools&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://percy.io/&quot;&gt;Percy.io&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/bbc/wraith&quot;&gt;Wraith&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/HuddleEng/PhantomCSS&quot;&gt;PhantomCSS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;UI testing&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;What is UI testing?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;UI testing is a technique used by end-to-end testing whose main aspect is to check how the application handles user actions performed via input devices - mouse, keyboard, and others. Another one is to check if displayed elements on the page are interacting correctly.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why you should do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Imagine that by an accident, your application has a faulty UI element, which is core for your business. Your users won&apos;t be able to get what they want, book an appointment, or buy a book. You will lose money and for sure clients, because with no trust in the application - you can&apos;t build the value.&lt;/p&gt;
&lt;p&gt;By that, UI testing is fundamental. Tests will behave like a real user. Will interact with your application and check the output. What&apos;s better, they will do more than check the presentation layer. A complex test needs the business and data layer also working.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;How you can do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;There are various tools created for control browsers. Some of them, you will find at the end of this caption. These tools will give you the possibility to create a test, which behaviors should be designed as a real user. Running them every every deploy, you&apos;ll always know, if somethings break. Also, you can set up these tests in the deployment pipeline.&lt;/p&gt;
&lt;p&gt;But... Not all that&apos;s pretty. These tests are slow. By slow, I mean that everyone needs to load a page, interact with it, probably reload, etc. This takes time. Many tests, takes much time to create an output, so it&apos;s important to run only the core one. More about it, you&apos;ll find in my latest article - &lt;a href=&quot;https://kodziak.com/blog/what-is-smoke-sanity-regression-testing-how-to-ci-cd-with-them&quot;&gt;click&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;For sure, you shouldn&apos;t give up on them. We always need to provide a complete working application.&lt;/p&gt;
&lt;h3&gt;Deployment diagram&lt;/h3&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Popular tools&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.cypress.io/&quot;&gt;Cypress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://playwright.dev/&quot;&gt;Playwright&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.selenium.dev/&quot;&gt;Selenium&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;API testing&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;What is API testing?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The API testing is a set of actions, which includes sending calls to API to get output and validate the response against defined input parameters. They determine if the API returns the correct response or react correctly to failures or unexpected behavior. Instead of using standard user inputs, we use the software.&lt;/p&gt;
&lt;p&gt;They&apos;re different than UI testing because don&apos;t concentrate on the presentation layer and the feel of the application. The main point is to check the business layer.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why you should do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;When you modify code in the backend, automated UI tests can be time-consuming and repetitive. With API testing we skip UI, which makes tests much faster. That&apos;s why we will know faster if our changes break business behavior.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;How you can do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;These tests can run similarly to UI ones. The main aspect is that you need a freshly build API, then you can run tests and base on the result deploy the new version of the application, or reject changes.&lt;/p&gt;
&lt;p&gt;There are many various tools to perform API tests. Some of them, I&apos;ve put below. Designing and writing API tests is crucial for business work. Especially, when your architecture is built on micro-services. You can check every one separately.&lt;/p&gt;
&lt;h3&gt;Deployment diagram&lt;/h3&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Popular tools&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.postman.com/&quot;&gt;Postman&lt;/a&gt; + &lt;a href=&quot;https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/&quot;&gt;Newman (if you want to run collections from CLI)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/supertest&quot;&gt;Supertest&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Performance testing&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;What is Performance testing?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Performance testing is a non-functional testing technique that determines the speed, scalability, stability, and responsiveness of an application under a particular workload. The goal of this type of test is to evaluate application output, speed, data transfer velocity, network bandwidth usage, and response times.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why you should do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;You need to know if application speed meets expectations on production. Performance is a key determinant of adoption, success, and productivity.&lt;/p&gt;
&lt;p&gt;Running them, you will identify performance-related bottlenecks, which affect the user and created a poor experience - where you lost money. Bottlenecks are a single point or component within a system&apos;s overall function, that holds back overall performance.&lt;/p&gt;
&lt;p&gt;You can also use them to compare two or more systems and identify the one that performs better.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;How you can do them?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;This is specified by organization and application. It depends on what you need and what the business considers most important.&lt;/p&gt;
&lt;p&gt;You can use some of the tools, which I&apos;ve listed below.&lt;/p&gt;
&lt;h3&gt;Deployment diagram&lt;/h3&gt;
&lt;p&gt;Researching this post I&apos;ve found some interesting articles on how to build a pipeline with performance tests. I&apos;m not sure if it&apos;s working well, but - why not to get a try?:)&lt;/p&gt;
&lt;p&gt;Here a few links:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://techbeacon.com/app-dev-testing/how-build-performance-testing-pipeline&quot;&gt;https://techbeacon.com/app-dev-testing/how-build-performance-testing-pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://speedcurve.com/blog/performance-testing-in-ci-lets-break-the-build/&quot;&gt;https://speedcurve.com/blog/performance-testing-in-ci-lets-break-the-build/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Popular tools&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jmeter.apache.org/&quot;&gt;Apache JMeter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://loadninja.com/&quot;&gt;LoadNinja&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.smartmeter.io/&quot;&gt;SmartMeter.io&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The listed types of tests has pros and cons. All of them are useful, and many you should have in your projects. Of course, everything depends on needs.&lt;/p&gt;
&lt;p&gt;We&apos;ve discussed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Screenshot testing,&lt;/li&gt;
&lt;li&gt;UI testing,&lt;/li&gt;
&lt;li&gt;API testing,&lt;/li&gt;
&lt;li&gt;Performance testing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope, that this article clarifies to you a bit which types could be useful where and for what we&apos;re doing them.&lt;/p&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>What is smoke, sanity, regression testing? How to CI/CD with them.</title><link>https://kodziak.com/blog/what-is-smoke-sanity-regression-testing/</link><guid isPermaLink="true">https://kodziak.com/blog/what-is-smoke-sanity-regression-testing/</guid><description>With growing test architecture, we are facing various problems. Execution time, flakiness, duplicate test cases etc. Tests are becoming hard to manage and we may start to feel like writing and maintaining them is meaningless.</description><pubDate>Sat, 12 Dec 2020 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;With growing test architecture, we are facing various problems. Execution time, flakiness, duplicate test cases etc. Tests are becoming hard to manage and we may start to feel like writing and maintaining them is meaningless.&lt;/p&gt;
&lt;p&gt;While lurking on reddit I came across a discussion about test types. Then it hit me - why can&apos;t we categorize them and instead of one long run, perform them group by group? We won&apos;t lose any coverage, and we&apos;ll reduce time to market. 🥳&lt;/p&gt;
&lt;h2&gt;Types of end-to-end tests&lt;/h2&gt;
&lt;p&gt;Sticking to E2E tests only, after reading the reddit discussion and thinking about the topic, I&apos;ve decided classify them into:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;smoke testing,&lt;/li&gt;
&lt;li&gt;sanity testing,&lt;/li&gt;
&lt;li&gt;regression testing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You probably already know the last group very well (if not → &lt;a href=&quot;https://www.softwaretestinghelp.com/regression-testing-tools-and-methods/&quot;&gt;click here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Now let&apos;s dig into each of the types mentioned before.&lt;/p&gt;
&lt;h3&gt;Smoke testing&lt;/h3&gt;
&lt;p&gt;The main characteristics of these tests are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They&apos;re performed to cover critical functionalities of the application (Priority1 scenarios),&lt;/li&gt;
&lt;li&gt;The objective is to verify &quot;stability&quot; of the application to continue with further testing,&lt;/li&gt;
&lt;li&gt;They&apos;re a subset of regression tests,&lt;/li&gt;
&lt;li&gt;They&apos;re like a general health check up,&lt;/li&gt;
&lt;li&gt;Failing these tests results in instant rejection.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Simply speaking, smoke testing should cover the most critical parts, the ones that let us confirm that the applications is working and delivers business value.&lt;/p&gt;
&lt;p&gt;For example, this kind of scenario could be in this category:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[Netflix.com] User can log in, choose a tv series/movie and start watching.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Sanity testing&lt;/h3&gt;
&lt;p&gt;Next group is sanity tests, whose main aspects are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They&apos;re performed to check more detailed functionalities of the application (Priority2 scenarios),&lt;/li&gt;
&lt;li&gt;The objective is to verify &quot;rationality&quot; of the application to continue with further testing,&lt;/li&gt;
&lt;li&gt;They&apos;re a subset of regression tests,&lt;/li&gt;
&lt;li&gt;They&apos;re like a detailed health check-up,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In simple words, sanity tests should cover more specialized user actions.&lt;/p&gt;
&lt;p&gt;Here&apos;s an example of a scenario that falls into this category:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[Netflix.com] User can search for movies using search bar.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can imagine, sanity tests may have some test cases in common with smoke tests but also there are certain differences between these categories.&lt;/p&gt;
&lt;h3&gt;Regression testing&lt;/h3&gt;
&lt;p&gt;Last but not least - regression tests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They&apos;re performed to check detailed functionalities of the application (Priority1 + Priority2 + Priority3 scenarios)&lt;/li&gt;
&lt;li&gt;The objective is to verify every existing feature of the application,&lt;/li&gt;
&lt;li&gt;Regression test cases should be well documented,&lt;/li&gt;
&lt;li&gt;They&apos;re like a comprehensive health check-up,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Simply speaking, regression tests should cover all the aspects of application - the important and less important ones. Executing regression tests should give us an overview that everything works properly.&lt;/p&gt;
&lt;p&gt;For example, a scenario that could be in this category is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[Netflix.com] User can open &quot;more information&quot; about a tv series/movie and choose genre.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Amount of tests by type&lt;/h3&gt;
&lt;p&gt;Regression tests &amp;gt; Sanity tests &amp;gt; Smoke tests.&lt;/p&gt;
&lt;p&gt;And here&apos;s a visual representation of how the sets intersect.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Arrange a deployment process based on test types&lt;/h2&gt;
&lt;p&gt;I&apos;ve worked with one test database and deployment process for a while, and I figured that it&apos;s not perfect and not bad, but as it grows, it needs some changes.&lt;/p&gt;
&lt;p&gt;Depending on the type of tests, we can choose the most important ones and those that are less important. As we all know, the most important ones are those that deliver the business value, so we have to check if those functionalities work as expected with every deploy. Based on these criteria we can design our deployment process.&lt;/p&gt;
&lt;p&gt;Working with an application based on CI/CD carries potential challenges such as designing a deployment process with automation testing. Because we don&apos;t want it to be long, we can categorize the tests, and run each group at a different time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you can see, only smoke tests are run with each application deploy. This way we&apos;ll always know that the most important functionalities work.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;As the number of your tests grows, they become harder to maintain. Running all of them after every deployment consumes too much time. If you organize them into categories you will reduce time to market without losing any necessary coverage.&lt;/p&gt;
&lt;p&gt;How you categorize your tests depends on you. They don&apos;t necessarily need to be divided into smoke, sanity and regression categories. You can do it differently, for example, by criticality level.&lt;/p&gt;
&lt;p&gt;Automated testing in deployment process is a standard practice in modern software development, used by the best teams and companies. CI/CD should therefore depend on the results of our tests, which will ensure that the critical functionalities always work.&lt;/p&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>Who is a Quality Assurance Engineer and what should he know?</title><link>https://kodziak.com/blog/who-is-a-qa-engineer-and-what-should-he-know/</link><guid isPermaLink="true">https://kodziak.com/blog/who-is-a-qa-engineer-and-what-should-he-know/</guid><description>Have you ever think about steps in the testing journey? Manual tester, QA, QA Engineer, Test Developer, SDET, TestOps? There are many ways you can develop in. But today, I want to stick with one - QA Engineer.</description><pubDate>Sun, 17 Jan 2021 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you ever think about steps in the testing journey? Manual tester, QA, QA Engineer, Test Developer, SDET, TestOps? There are many ways you can develop in. But today, I want to stick with one - QA Engineer.&lt;/p&gt;
&lt;p&gt;What does exactly this person do? What are the responsibilities and requirements? What should he know to work efficiently on daily basis?&lt;/p&gt;
&lt;p&gt;I&apos;ve summed up areas and described basing on daily tasks.&lt;/p&gt;
&lt;h2&gt;What does a QA Engineer do?&lt;/h2&gt;
&lt;p&gt;QA Engineer means Quality Assurance Engineer is a specialist whose activities are aimed to improve the software development process and product quality using engineering knowledge. Manual tests aren&apos;t optimal in most cases. QA engineers automate the most common cases, which saves us time and money.&lt;/p&gt;
&lt;p&gt;Responsibilities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;write, design, and execute automated tests,&lt;/li&gt;
&lt;li&gt;maximize test coverage,&lt;/li&gt;
&lt;li&gt;determine the priority for test scenarios,&lt;/li&gt;
&lt;li&gt;create execution plans for these scenarios,&lt;/li&gt;
&lt;li&gt;write documentation for automated processes,&lt;/li&gt;
&lt;li&gt;build automation frameworks,&lt;/li&gt;
&lt;li&gt;set up continuous integration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And to reach the QA Engineer job, you need to know various things. I&apos;ve categorized and described them.&lt;/p&gt;
&lt;h2&gt;Methodologies&lt;/h2&gt;
&lt;p&gt;You&apos;ll be obligated to write, design, and execute automated tests. It means you have to know how to do it. Writing automation tests isn&apos;t something very different than you&apos;re doing manually. I mean, to write this one, you have to perform these steps manually. So you have to take exactly the same steps as a user, and write this as a script. Experience with manual testing will let you write these scripts better.&lt;/p&gt;
&lt;p&gt;From time to time, you&apos;ll also decide what&apos;s important, and what&apos;s not. What should be tested next, and how to maximize test coverage. Experience and knowledge about methodologies will help you with these decisions.&lt;/p&gt;
&lt;p&gt;The priority of scenarios? Another important topic. Creating complex test solutions, most sure you&apos;ll face a problem with them. What should we automate first and why? What should we run first? These are hard questions, but important. We should always focus on more important parts of the application. Because we don&apos;t want to show the user some unexpected behaviors, bugs, or unavailability of the website. They&apos;ll lose trust in our product, which we can&apos;t afford.&lt;/p&gt;
&lt;h2&gt;Programming language&lt;/h2&gt;
&lt;p&gt;Writing tests, creating test frameworks and architecture is the same as with applications. To do this, you need to know a programming language.&lt;/p&gt;
&lt;p&gt;Some of the wanna-be test developers, decide to learn frameworks first. Without the proper programming knowledge, they&apos;re trying to write tests. Probably this gonna work, but this solution won&apos;t be maintainable so much. While growing, they will encourage more and more problems, because basics were created wrong. Fix these mistakes lately, will cost much more time and afford than proper planning.&lt;/p&gt;
&lt;p&gt;But language knowledge isn&apos;t in my opinion enough. You should also be familiar with the concepts of programming. KISS, YAGNI, DRY, SOLID - right now, they could sound for you like a buzz word, but believe me - you&apos;ll use them daily. Knowing them will give you the opportunity of creating more maintainable and better solutions.&lt;/p&gt;
&lt;p&gt;Sometimes you&apos;ll also need to pass framework methods. Instead of using a &lt;code&gt;page.click()&lt;/code&gt; you&apos;ll need to perform language native one. Sometimes, you&apos;ll need an API call that your test framework doesn&apos;t wrap up. You&apos;ll face many cases, where knowledge of the language is important.&lt;/p&gt;
&lt;p&gt;Languages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;JavaScript/TypeScript,&lt;/li&gt;
&lt;li&gt;Java,&lt;/li&gt;
&lt;li&gt;C#,&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Test tools&lt;/h2&gt;
&lt;p&gt;To write a test we&apos;re using test frameworks. These are tools set, out of the box, which gives you an easy way to control the browser. It means, writes a user like a scenario end&apos;s with a few methods. We don&apos;t have to reinvent a wheel, write from scratch integration with browser, etc.&lt;/p&gt;
&lt;p&gt;Tooling is important, but concepts are more. While you know one test framework, you can easily switch to another. Most of them are very similar, it&apos;s like with a programming language, while you know the concepts and knows how to program, a language is literally a tool.&lt;/p&gt;
&lt;p&gt;Example test frameworks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Playwright,&lt;/li&gt;
&lt;li&gt;Cypress,&lt;/li&gt;
&lt;li&gt;Selenium&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Processes&lt;/h2&gt;
&lt;p&gt;One of the bigger challenges is to set up pipelines. Nowadays, we&apos;re using Continuous Integration practice. Design and build a whole process is a very valuable skill.&lt;/p&gt;
&lt;p&gt;You need to understand how deployment works, where you can run tests, how to do this?&lt;/p&gt;
&lt;p&gt;To reach this, be familiar with topics like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Docker,&lt;/li&gt;
&lt;li&gt;CI/CD - Gitlab, Jenkins,&lt;/li&gt;
&lt;li&gt;Cloud - AWS, Azure&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There&apos;s a role called TestOps which is a connection between operations and testing, but I think mature QA Engineers should know the basics about processes, to be able to set up them from scratch.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;QA Engineer role requires knowledge of many different areas. All of them affect the final solution, which with this knowledge will be better.&lt;/p&gt;
&lt;p&gt;Knowledge of these areas also allows you to develop in various roles. Dive into processes? You can go into the TestOps position. Development? Then pick SDET.&lt;/p&gt;
&lt;p&gt;Have a nice day! 🥳&lt;/p&gt;
</content:encoded></item><item><title>Why do most test engineers fail interviews?</title><link>https://kodziak.com/blog/why-do-most-test-engineers-fail-interviews/</link><guid isPermaLink="true">https://kodziak.com/blog/why-do-most-test-engineers-fail-interviews/</guid><description>Recently I had the pleasure of interviewing candidates for my QA team. Sometimes, they were hard. You may ask why so I&apos;ll try to explain. I hope that in the future we can teach and prepare wanna-be test engineers to pass every interview they want to:)</description><pubDate>Fri, 20 Nov 2020 08:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Recently I had the pleasure of interviewing candidates for my QA team. Sometimes, they were hard. You may ask why so I&apos;ll try to explain. I hope that in the future we can teach and prepare wanna-be test engineers to pass every interview they want to:)&lt;/p&gt;
&lt;p&gt;Our roadmap for this article:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Basics of the language&lt;/li&gt;
&lt;li&gt;Compatibility with the team&lt;/li&gt;
&lt;li&gt;Problem-solving&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Basics of the language&lt;/h3&gt;
&lt;p&gt;In my opinion, knowing the basics of the language you want to use to write automated tests is quite important to write them well.&lt;/p&gt;
&lt;p&gt;Many wanna-be test engineers (and not only beginners) know how to write a test, but when it comes to creating a custom solution - it could be hard without the basics of the language. In my daily work I&apos;m facing various problems. Sometimes I&apos;m just writing tests, which is kinda repetitive and easy, but there’s been many situations when we had to create some custom solution to simplify our work (like our custom runner, based on &lt;code&gt;jest&lt;/code&gt; or &lt;code&gt;TestKeeper&lt;/code&gt; which is an application to handle tests by micro-services). In this situation, I&apos;m pretty sure that they could write this, but the quality of the code would probably be awful and hard to maintain. It&apos;s not the point:)&lt;/p&gt;
&lt;p&gt;And to give you an example. One of my questions was very simple: what’s the difference between let, const, and var? It&apos;s a very basic question often asked in interviews. And you know what? Many of the candidates couldn&apos;t answer it. I was kinda shocked because it&apos;s like the first question from the Top Ten JS interview questions.&lt;/p&gt;
&lt;h3&gt;Compatibility with the team&lt;/h3&gt;
&lt;p&gt;Another important aspect of the recruitment process is your compatibility with the team. I mean, if your approach and personality doesn&apos;t fit the team – you won&apos;t be processed to the next stages. And there’s nothing wrong with that. It&apos;s not your fault but you have to be aware of this.&lt;/p&gt;
&lt;p&gt;I&apos;m mentioning this because for us, leaders, it&apos;s a very important topic when building the right team.&lt;/p&gt;
&lt;p&gt;But... I can give you some tips, what skills a good tester should have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;proactivity,&lt;/li&gt;
&lt;li&gt;problem-solving,&lt;/li&gt;
&lt;li&gt;business point of view,&lt;/li&gt;
&lt;li&gt;flexibility,&lt;/li&gt;
&lt;li&gt;quick learner,&lt;/li&gt;
&lt;li&gt;collaboration and social skills,&lt;/li&gt;
&lt;li&gt;communication skills,&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Problem-solving&lt;/h3&gt;
&lt;p&gt;As you may have guessed, the quality that I particularly value is the problem-solving attitude. And it’s essential not only during the interview but also on a daily basis. But what does it mean?&lt;/p&gt;
&lt;p&gt;In my opinion, a good tester shouldn&apos;t be afraid of confronting problems. Sometimes people come to us and ask difficult questions – it&apos;s just daily work. We should try to face them and if at that moment we don&apos;t know the answer – ask around and try to find it. Probably this asking part will be connected with doing something so treat it as a challenge.&lt;/p&gt;
&lt;p&gt;In my recent interviews I met various candidates. Some of them, when given a task, tried to solve it, even if they haven’t encountered a similar problem before. The answer from another group was &quot;I don&apos;t know&quot;, and it was wrong. I mean, when you don&apos;t have experience in a given topic, just say it and try to answer what you feel it could be. I&apos;m not saying it&apos;s the best approach every time to every question but I really like it when someone tries to give an answer with their own words, just thinking about how it could work. We could at that moment recognize how each of the candidates handled challenges and problems.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Going through interviews is hard and most of the time – stressful. It&apos;s not a piece of cake but proper preparation before the talk should help you get the job. In my opinion, as I&apos;ve written above, you have to go with a proper attitude and thorough knowledge of the language basics. But of course it&apos;s not everything, these are just the fundamentals you should have. The rest depends on the position you’re applying for, your seniority and experience.&lt;/p&gt;
&lt;p&gt;I hope this article gives you an idea of some basic problems which are easy to tackle and could boost your confidence in interviews.&lt;/p&gt;
&lt;p&gt;Useful articles to help you build your future career:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://medium.com/docplanner-tech/few-things-to-remember-when-you-apply-for-a-job-44ac6c4efd8d&quot;&gt;https://medium.com/docplanner-tech/few-things-to-remember-when-you-apply-for-a-job-44ac6c4efd8d&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://fearlesssalarynegotiation.com/salary-expectations-interview-question/&quot;&gt;https://fearlesssalarynegotiation.com/salary-expectations-interview-question/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Have a nice day!&lt;/p&gt;
</content:encoded></item><item><title>Why it&apos;s so hard to get rid of bad habits?</title><link>https://kodziak.com/blog/why-its-so-hard-to-get-rid-of-bad-habits/</link><guid isPermaLink="true">https://kodziak.com/blog/why-its-so-hard-to-get-rid-of-bad-habits/</guid><description>Some time ago I read a book - The Power of Habits, written by Charles Duhigg. I wanted to learn, how to manage my habits and the most - how to get rid of the bad ones. The author of this book tries to prove, that everything which we&apos;re doing can change. Just by changing our doing path. This can change our whole life.movement to my initiatives?</description><pubDate>Sat, 24 Oct 2020 10:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Some time ago I read a book - The Power of Habits, written by Charles Duhigg. I wanted to learn, how to manage my habits and the most - how to get rid of the bad ones. The author of this book tries to prove, that everything which we&apos;re doing can change. Just by changing our doing path. This can change our whole life.&lt;/p&gt;
&lt;h3&gt;What is a habit?&lt;/h3&gt;
&lt;p&gt;Habit is the thing you&apos;re doing without thinking. For example, if you&apos;re daily eating dinner at 1 p.m. - it&apos;s a habit. In coding - if you, for example: have own style of brackets,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if () {

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if ()
{

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You aren&apos;t thinking when writing brackets in your code. We call this easily as a habit. Bad, good - it&apos;s your pick.&lt;/p&gt;
&lt;h3&gt;Types of habits&lt;/h3&gt;
&lt;p&gt;There are good habits, neutral ones and also... bad ones.&lt;/p&gt;
&lt;p&gt;Of course, we want to get rid of the last ones. But we can&apos;t. Why?&lt;/p&gt;
&lt;p&gt;Bad habits are challenging. They&apos;re difficult to overcome, especially, when we have them for the whole life.&lt;/p&gt;
&lt;h3&gt;How to get rid of them?&lt;/h3&gt;
&lt;p&gt;We should follow two steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Recognition. You have to look at them and ask yourself: How long I&apos;m doing this shit?&lt;/li&gt;
&lt;li&gt;Realize. You have to realize, that what you&apos;re doing is wrong. You have to realize, that the process to change this habit won&apos;t be comfortable. It&apos;s gonna be hard.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Take the example of trying to eat more healthly.&lt;/p&gt;
&lt;p&gt;Starting from being fatty, if you develop a habit of doing workout 3-4 times a week and eating healthier, in some months you can change your styling about one hundred percent. It sounds great, yea? But it&apos;s hard to develop. We aren&apos;t prepared to change our habits (like eating trashy food) in one second. Saying: &quot;I won&apos;t eat that food from now&quot; and trying to do this - probably you will fail. That&apos;s about what Charles tries to explain - we have to do this by small steps. We want to reach the goal fast, but we can&apos;t. We will fail. But if we will start with small steps, as I mentioned earlier, we could probably win.&lt;/p&gt;
&lt;p&gt;For an example of eating healthy. Start with eating one of five meals healthier. After some time, add another one, and another and another. In the end, you will change your whole eating habit and probably, you won&apos;t want to get back into trashy one, because your style change and you will look better.&lt;/p&gt;
&lt;p&gt;We can do this way with every habit. I&apos;ve used this for reading books. A few years ago I didn&apos;t read. Zero books in a whole year - for now, me, it sounds ridiculous, such a waste of time. I could read many brilliant books and have much more knowledge than now, which probably could give me more money or feel better with myself.&lt;/p&gt;
&lt;p&gt;But you still need to remember. It&apos;s going to take time. It&apos;s going to take commitment, and it&apos;s going to take perseverance.&lt;/p&gt;
&lt;p&gt;It&apos;s a slow process.&lt;/p&gt;
&lt;h3&gt;Applications&lt;/h3&gt;
&lt;p&gt;Apps can help out us here. Many of them allow us to pick a habit which we want to develop and every day if we mark as done, the line will look good (line of progress).&lt;/p&gt;
&lt;p&gt;I&apos;m using &lt;a href=&quot;https://www.thehabithub.com/&quot;&gt;https://www.thehabithub.com/&lt;/a&gt; and totally recommend it. It&apos;s simple, easy to use application decicated to habits. Try it:)&lt;/p&gt;
&lt;p&gt;Similar apps you can find in &lt;a href=&quot;https://www.reddit.com/r/Habits/&quot;&gt;https://www.reddit.com/r/Habits/&lt;/a&gt;, where are many fantastic people which trying to change their lives, by improving habits.&lt;/p&gt;
&lt;p&gt;Also, you can try &lt;a href=&quot;https://habitica.com/&quot;&gt;Habitica&lt;/a&gt;, which I didn&apos;t even try, but many people recommended it to me.&lt;/p&gt;
</content:encoded></item><item><title>Why you should have financial cushion?</title><link>https://kodziak.com/blog/why-you-should-have-financial-cushion/</link><guid isPermaLink="true">https://kodziak.com/blog/why-you-should-have-financial-cushion/</guid><description>Yesterday I didn&apos;t know how to manage an income. I thought it&apos;s very complex to build a financial cushion, manage two accounts, invest money or just simply not live beyond the state.</description><pubDate>Thu, 03 Sep 2020 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Yesterday I didn&apos;t know how to manage an income. I thought it&apos;s very complex to build a financial cushion, manage two accounts, invest money or just simply not live beyond the state.&lt;/p&gt;
&lt;p&gt;I&apos;ve made some simple steps to save money for my future. And if we want to talk about saving, I have one rule.&lt;/p&gt;
&lt;h3&gt;Don&apos;t be stingy.&lt;/h3&gt;
&lt;p&gt;If I want to buy a new laptop? Why not - it&apos;s my cash, I earn it. But not so fast, this expense shouldn&apos;t be as fast as I wrote this sentence. I&apos;ve rule, that if I think about it for about month (or less, but still not like to think -&amp;gt; buy in ten seconds), this says to me that I need it. It&apos;s even better if this expense is helpful in earning money.&lt;/p&gt;
&lt;h3&gt;Why I need financial cushion?&lt;/h3&gt;
&lt;p&gt;Financial cushion guarantees you, that if you have smaller or bigger expenses and troubles at that time, you won&apos;t have to take an loan to finance them. Pillows give you an opportunity to move on this hard time without any major perturbations. But imagine, that at this moment you don&apos;t have savings - it&apos;s a straight line to snare bank and living on credit.&lt;/p&gt;
&lt;p&gt;That&apos;s why financial cushion is like armor to help you go through financial problems easy way.&lt;/p&gt;
&lt;h3&gt;Ok, but how big it should be?&lt;/h3&gt;
&lt;p&gt;That&apos;s a tricky question. My personal savings need to cover my normal life (without a job) for about half a year. But I&apos;m single, living in a big city without any large monthly expenses. In a fast way, I can go back to my family&apos;s house and cut my costs by about 50%. You can have a harder situation.&lt;/p&gt;
&lt;p&gt;I think fit for everyone divisions should be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;3-6 months -&amp;gt; if you are single and you&apos;re not a source for family,&lt;/li&gt;
&lt;li&gt;6-12 months -&amp;gt; if you have a family and kids,&lt;/li&gt;
&lt;li&gt;12+ months -&amp;gt; if you have a family and running a company.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;How to do this right?&lt;/h3&gt;
&lt;p&gt;I&apos;ve got a simple system to manage my incomes. We need two accounts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the primary account is where your income goes. You pay bills from this account, have a credit card connect with it and you cover all expenses from this account,&lt;/li&gt;
&lt;li&gt;the secondary account is only for savings. You store here your cash and this account doesn&apos;t have a connected credit card, so you can&apos;t easily pay with this money. I also prefer to limit this account only to one transfer a month (of course, two and more are possible, but you have to pay for them).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But I strongly recommend splitting your financial cushion from typical savings for a target. Probably you need some kind of investment account, but be careful, because if you need this money, you could be able to use them in a short time.&lt;/p&gt;
&lt;p&gt;But always remember.&lt;/p&gt;
&lt;h3&gt;Pay yourself first&lt;/h3&gt;
&lt;p&gt;If you want to build a financial cushion fast, you need to prepare a plan and stick to it. In my opinion, if you won&apos;t pay yourself first a specified amount of money, sometimes you will forget to do it, or just pay a smaller amount for any reason. It&apos;s dangerous. The best if you set up an automatic payment a few days after income goes to your primary account.&lt;/p&gt;
&lt;p&gt;I hope you will get something from this post. We all need to be prepared to worst times than we expect they&apos;re gonna be - it&apos;s important.&lt;/p&gt;
&lt;p&gt;Have a nice day.&lt;/p&gt;
</content:encoded></item></channel></rss>