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:fix