Use an Agent to interact with the Internet Computer from your JavaScript program.
This source code repository contains multiple npm packages, each under ./packages/
.
npm i -g npm
npm install
After that, you probably want to dive into a specific package in ./packages.
Running tests is a good way to get a sense of what the features will do. We try to have full unit test coverage for all new features, although sometimes mocking network conditions can be difficult, and e2e tests may be preferable.
To run the unit tests for all packages, run npm test
. You can run tests for a specific package by running npm test
in the package directory or by running npm test --workspace=<package-name>
in the root directory.
There are two sets of e2e tests in this repository. They are located in e2e/browser
and e2e/node
. The browser tests are run in a headless browser, and the node tests are run in a node environment. The node tests are faster and require less setup, but the browser tests can simulate relevant environmental conditions.
Important Note: the e2e tests do not run from the TypeScript source code of projects and must be compiled. You should run
npm run build
to compile the projects after your changes before running the tests.
To run the e2e node tests, you can run
dfx start --background --clean
npm run e2e --workspace e2e/node
dfx stop
We expect you to have the replica running on port 4943
. If you are using a different port, you can set an environment variable REPLICA_PORT
to the port number.
Note: browser tests have been temporarily removed pending a rewrite
To run the e2e browser tests, you can run
dfx start --background --clean
npm run setup --workspace e2e/browser
npm run e2e --workspace e2e/browser
dfx stop
We use npm
to manage this repo and its packages. A few useful
commands to keep in mind;
npm run test
.npm run e2e
. WARNING: You need to have a running
replica locally. In our CI runs, we use the ic-ref
which is not (at this time) available
publicly. Normally you can use a replica distributed with dfx (ie. dfx start in a project),
but there is no guarantee that the next
branch will work with the latest published dfx.
Once you have a replica running locally, you must pass the port to the e2e tests using the
REPLICA_PORT
environment vairable. If that variable is not set, the tests will fail.The following scripts can be found in ./bin:
Monorepo-related scripts run in this order, but are usually invoked by npm install
:
npm run postinstall
in this monorepo package.
npm run build
) each subpackage in ./packages/npm test
in each subpackageContributions are welcome! Please refer to the CONTRIBUTING.md, where you can find more details about:
This project is licensed under the Apache-2.0 License.