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
- Node ( greater then 12.0 version ) - https://nodejs.org/en/
- 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:
sh -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.
- Open PowerShell (Instructions)
- In PowerShell, run:
iex "& { $(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
-
To clone kitty-itmes repo open git bash in your desired folder and run below command
git clone https://github.com/onflow/kitty-items.git
-
After that, go to cadence tests folder
cd kitty-items\cadence\tests
-
Install NPM dependancies using
npm install
command.npm install
-
To run the testcase of kitty items run the below command
npm run test
Note: Here, i have changes test case per our Smart contarct requirement
I hope it’s help you, All the best 👍.