Skip to content

Commit

Permalink
test(contracts): migrate from Jest to Vitest (#264)
Browse files Browse the repository at this point in the history
* test: migrate contracts test suite to Vitest

* ci: run contracts test before Playwright

* fix(tests): Wait for sendRawTransaction as part of incrementRoundNumberBy helper function

* ci: only run ci-tests workflow on PRs into main

---------

Co-authored-by: Patrick Bennett <[email protected]>
  • Loading branch information
drichar and pbennett authored Aug 1, 2024
1 parent 112441d commit 10913b9
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 388 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: Playwright Tests
name: Contract/Playwright Tests
on:
push:
branches:
- 'main'
pull_request:
branches:
branches:
- 'main'
# - 'dev'

jobs:
playwright-tests:
ci-tests:
timeout-minutes: 60
runs-on: ubuntu-latest

Expand Down Expand Up @@ -66,6 +63,9 @@ jobs:
- name: Start local Algorand network
run: algokit localnet start

- name: Run Contract tests from already built contracts
run: pnpm --filter ./contracts run retest

- name: Bootstrap the validator
run: pnpm run bootstrap

Expand Down
2 changes: 1 addition & 1 deletion contracts/__test__/contracts.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from '@jest/globals'
import { afterEach, beforeAll, beforeEach, describe, expect, test } from 'vitest'
import { algoKitLogCaptureFixture, algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { consoleLogger } from '@algorandfoundation/algokit-utils/types/logging'
import { AlgoAmount } from '@algorandfoundation/algokit-utils/types/amount'
Expand Down
11 changes: 1 addition & 10 deletions contracts/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,16 +987,7 @@ export async function incrementRoundNumberBy(context: AlgorandTestAutomationCont
})
txnid = txn.txID()
const signedTransaction = await signTransaction(txn, context.testAccount)
context.algod.sendRawTransaction(signedTransaction).do()
// await algokit.transferAlgos(
// {
// from: context.testAccount,
// to: context.testAccount,
// amount: AlgoAmount.Algos(1),
// suppressLog: true,
// },
// context.algod,
// )
await context.algod.sendRawTransaction(signedTransaction).do()
}
// wait for the final transaction to show up...
await waitForConfirmation(txnid, rounds + 1, context.algod)
Expand Down
6 changes: 0 additions & 6 deletions contracts/jest.config.js

This file was deleted.

10 changes: 4 additions & 6 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"generate-components": "algokit-generate-component contracts/artifacts/validatorRegistry.arc32.json contracts/artifacts/components",
"noalgobuild": "pnpm run compile-contract -- --skip-algod && pnpm run generate-client",
"build": "pnpm run compile-contract && pnpm run generate-client",
"test": "pnpm run build && jest",
"retest": "jest",
"test": "pnpm run build && vitest",
"retest": "vitest",
"lint": "eslint . --ext ts --max-warnings 0",
"lint:fix": "eslint . --ext ts --max-warnings 0 --fix",
"prettier": "npx prettier --check .",
Expand All @@ -22,7 +22,6 @@
"devDependencies": {
"@algorandfoundation/algokit-client-generator": "^3.0.2",
"@algorandfoundation/tealscript": "^0.98.0",
"@jest/globals": "^29.7.0",
"@joe-p/algokit-generate-component": "^0.2.1",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
Expand All @@ -32,9 +31,8 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vitest": "2.0.3"
}
}
Loading

0 comments on commit 10913b9

Please sign in to comment.