This document provides guidance for testing the SDK.
To run unit tests, you can simply execute the command:
npm run test:unit
# or
yarn test:unit
Both test cases for the NodeJS environment and the browser (cypress) require preparation of a test environment of the Golem Network with Providers and all the necessary infrastructure.
- Ensure you have
docker
anddocker-compose
installed in your system. - Your Linux environment should have nested virtualization enabled.
Follow these steps to prepare your test environment:
First, build the Docker containers using the docker-compose.yml
file located under tests/docker
.
Execute this command to build the Docker containers:
docker-compose -f tests/docker/docker-compose.yml build
Then, launch the Docker containers you've just built using the same docker-compose.yml
file.
Execute this command to start the Docker containers:
docker-compose -f tests/docker/docker-compose.yml down && docker-compose -f tests/docker/docker-compose.yml up -d
The next step is to fund the requestor.
docker exec -t docker_requestor_1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"
Finally, install and build the golem-js SDK in the Docker container
Run this chain of commands to install and build the SDK and prepare cypress.
docker exec -t docker_requestor_1 /bin/sh -c "cd /golem-js && npm i && npm run build && ./node_modules/.bin/cypress install"
With your test environment set up, you can now initiate the E2E tests. Run the following command to start:
docker exec -t docker_requestor_1 /bin/sh -c "cd /golem-js && npm run test:e2e"
First make sure that the webserver that's used for testing is running, by running the command
docker exec -t -d docker_requestor_1 /bin/sh -c "cd /golem-js/examples/web && node app.mjs"
Now you're ready to start the cypress tests by running the command
docker exec -t docker_requestor_1 /bin/sh -c "cd /golem-js && npm run test:cypress -- --browser chromium"