https://github.com/thanasornsawan/end_to_end_testing_dapp_playwright_synpress
Implemented Page Object Model (POM) structure for Synpress (Playwright) to conduct end-to-end (E2E) testing on a lending smart contract. Developed a Solidity smart contract for lending ETH to WETH, supporting deposit, withdraw, borrow, and repay flows (with an annual interest rate), Also built a staking contract that allows users to stake WETH
https://github.com/thanasornsawan/end_to_end_testing_dapp_playwright_synpress
blockchain dapp dapps ethereum-contract ethersjs hardhat mocha-chai nextjs playwright playwright-typescript qa-automation reactjs smart-contracts solidity synpress testing web3
Last synced: 4 months ago
JSON representation
Implemented Page Object Model (POM) structure for Synpress (Playwright) to conduct end-to-end (E2E) testing on a lending smart contract. Developed a Solidity smart contract for lending ETH to WETH, supporting deposit, withdraw, borrow, and repay flows (with an annual interest rate), Also built a staking contract that allows users to stake WETH
- Host: GitHub
- URL: https://github.com/thanasornsawan/end_to_end_testing_dapp_playwright_synpress
- Owner: Thanasornsawan
- Created: 2025-02-04T09:22:28.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-26T06:11:14.000Z (4 months ago)
- Last Synced: 2025-02-26T07:20:41.312Z (4 months ago)
- Topics: blockchain, dapp, dapps, ethereum-contract, ethersjs, hardhat, mocha-chai, nextjs, playwright, playwright-typescript, qa-automation, reactjs, smart-contracts, solidity, synpress, testing, web3
- Language: TypeScript
- Homepage:
- Size: 3.28 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# E2E_blockchain_testing
## Topic DApp Web3 testing (Defi) with Synpress V4 and Playwright
Command to setup Metamask wallet:
```sh
npx synpress wallet-setup
```Command to run test cases with Synpress on hardhat local network
```sh
# Terminal 1: Start local network
npx hardhat node# Terminal 2: Deploy smart contract to local network
npx hardhat run scripts/deploy/deployAndUpdateAddresses.ts --network local# Terminal 3: Start the front-end server
cd frontend & npm run dev# Terminal 4: Run test cases with Playwright
npm run test:playwright:headless
```If you want to update oracle price manually, run command:
```sh
npx hardhat run scripts/utils/updatePrice.ts --network local
```If you want to simulate time pass for interest rate when borrow on local network, run command:
```sh
npx hardhat run scripts/utils/simulate-time-passage.js --network local
```## Topic Node Tesing on smart contract (Defi)
Refer blog https://medium.com/coinmonks/qa-blockchain-testing-smart-contract-network-performance-with-hardhat-d01e99e331e7
Command to run all test cases (refer backend test cases folder ./test/network)
```sh
# Terminal 1: Start local fork
npx hardhat node --fork https://eth-mainnet.alchemyapi.io/v2/YOUR_KEY# Terminal 2: Run tests
npm run test:main_network_fork_report
```## For DB setup (for integration testing with off-chain data)
**Install dependencies**
```sh
npm install @prisma/client
npm install prisma --save-dev
```
**Start postgresql db with Prisma on docker compose**
```sh
docker-compose up -d
```
**Push schema to database**
Creates the tables according to your Prisma schema
```sh
npx prisma db push
```
**Generate client**
Generates the TypeScript client for your application
```sh
npx prisma generate
```
**Check database tables**
```sh
npx prisma db pull
```
**Test db connection**
```sh
npx ts-node test-db-connection.ts
```
**Delete all db data**
```sh
npx ts-node scripts/utils/clearDatabase.ts
```