To set up your local development environment for working on this project, follow these steps:
Make sure you have Node.js and npm installed on your machine.
This package is built using node v19, so it is recommended to use that version.
We use Test Containers for running integration tests.
In our Test Containers setup we use Docker Compose, as our tests involve multiple containers that need to be orchestrated together.
If you want to run integration tests, you need Docker and Docker Compose installed on your machine.
Make sure that you install all the project dependencies:
npm installIn order to build the project, we need to run the following command:
npm run buildthe build generated will be placed in dist folder.
npm run testnpm run test:unitnpm run test:integrationIt's also possible to run individual tests. Below are some examples.
npm run test:unit UpdateCollectionFeaturedItems.test.tsnpm run test:functional UpdateCollectionFeaturedItems.test.tsnpm run test:integration CollectionsRepository.test.tsThe integration testing environment uses different environment variables, defined in a .env file, available in the test/integration/environment folder.
These environment variables can be updated as needed for integration testing. For example, we can specify the Dataverse image registry and tag, to point to the particular Dataverse image to test.
-
To test images generated in Dataverse PRs: Set
ghcr.ioas the image registry (DATAVERSE_IMAGE_REGISTRY) and the source branch name of a particular PR as the image tag (DATAVERSE_IMAGE_TAG). -
To test the Dataverse develop branch: Set
docker.ioas the image registry (DATAVERSE_IMAGE_REGISTRY) andunstableas the image tag (DATAVERSE_IMAGE_TAG).
npm run test:coverageIf you want to see the container logs while running integration or functional tests, run the following command before running the test commands:
export DEBUG=testcontainers:containers npm testnpm run formatRunning a linting check on the code:
npm run lintFix linting checks on the code:
npm run lint:fixTwo different versions are being pushed to the GitHub Packages registry:
-
PR-Generated Versions:
- These versions are generated from pull request commits.
- They follow the structure
<current_package_version>-pr<pr_number>.<commit_hash>, wherepr_numberis the number of the pull request, andcommit_hashis the specific commit hash from the PR branch. - These versions are unstable and correspond to the state of the package during the pull request.
-
Develop Alpha Versions:
- These versions are generated on every commit made to the
developbranch, ideally after each pull request is merged. - They follow the structure
<current_package_version>-alpha.<number>, wherenumberis an incremental value that starts at 1 and increases with each build. - These versions are also unstable and represent the latest work in progress on the
developbranch.
- These versions are generated on every commit made to the
These versions are great for developing a new SPA frontend feature integration. For instance, if you create a new use case in this repository and want to integrate the UI in the dataverse-frontend repository, you can use the PR-Generated Version. If the changes have already been merged, the Alpha Version will contain the new use case.