Navigate back to the homepage

Guide to use onflow flow-js-testing framework

Infinitbility
BlockChain
June 3rd, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To use flow-js-testing and run test cases of cadence smart contract, You have to install node.js, flow CLI after you able to run your test cases in flow emulator using npm run test command.

Note: Here, we are running kitty-items test cases For NFT cadence smart contract

Today, I’m going to show How do I run test cases of cadence smart contract using flow js testing, here I will use onflow kitty items repo https://github.com/onflow/kitty-items.

Let’s start the today’s tutorial How do you run test cases of cadence smart contract using flow js testing?

Prerequisite

  1. Node ( greater then 12.0 version ) - https://nodejs.org/en/
  2. Git bash ( To clone repos ) - https://git-scm.com/downloads

Installation

To run test case on flow emulator we to install Flow CLI on out Machine.

  • For MAC OS and Linux

This installation method only works on x86-64.

This script downloads and installs the appropriate binary for your system:

1sh -ci "$(curl -fsSL https://storage.googleapis.com/flow-cli/install.sh)"
  • For Windows

This installation method only works on Windows 10, 8.1, or 7 (SP1, with PowerShell 3.0), on x86-64.

  1. Open PowerShell (Instructions)
  2. In PowerShell, run:
1iex "& { $(irm 'https://storage.googleapis.com/flow-cli/install.ps1') }"

To update, simply re-run the installation command above.

Clone kitty-items and run test cases

  1. To clone kitty-itmes repo open git bash in your desired folder and run below command

    1git clone https://github.com/onflow/kitty-items.git
  2. After that, go to cadence tests folder

    1cd kitty-items\cadence\tests
  3. Install NPM dependancies using npm install command.

    1npm install
  4. To run the testcase of kitty items run the below command

    1npm run test
Onflow, flow-js-testing run testcases example
Onflow, flow-js-testing run testcases example

Note: Here, i have changes test case per our Smart contarct requirement

I hope it’s help you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How to create multiple nodes in the node-red single module?

Example of create multiple nodes in the node-red single module or package with step by step guide.

June 3rd, 2022 · 1 min read

How to check if number is prime in javascript?

Example of check if number is prime or not in javascript with step by step guide.

June 2nd, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]