Testing AlgonautJS
October 4, 2022 ยท View on GitHub
setup
- install
taskfilebrew install go-task/tap/go-task
- install
dotenvgloballynpm i -g dotenv
- configure
.env- set NCC_BASE_SERVER, NCC_API_TOKEN, etc
- FYI env vars need to have prefix
NCC_to work w vite server
run tests
task prepare-algonautjs- installs algonautjs deps + builds lib + links pkg locally
task prepare-tests- installs test dir deps + links to local instance of
@thencc/algonautjs
- installs test dir deps + links to local instance of
task tests- runs task called "tests" which runs all tasks defined in yaml
- FYI, there are many logs... but no errors in the console is a win
- list all tasks:
task --list - run 1 specific test:
task TASK_NAME
testing import/require
algonautjs should work in all js/ts contexts. but to be sure, we automate the various types of initializations such as:
- browser
- esm
- relative
- skypack
- vue (ts)
- react (ts)
- TODO
- js cdn
- TODO?
- esm
- node
- javascript
package.json> type >commonjspackage.json> type >module
- typescript
package.json> type >commonjspackage.json> type >module
- javascript
unit tests
Unit tests for algonaut are in algonaut.test.ts. Run them with:
npm run test
Unit tests require ALGONAUT_TEST_MNEMONIC to be set in the environment (.env is fine). This account must have a little bit of Algo in it to run the tests.
notes
- don't mock code you don't own! APIs change all the time! :)