This page describes how to set up the TypeScript and JavaScript tooling to build the Grapher component from source and test it in your browser on your local machine. If you also want to be able to use the admin UI to graphically configure grapher charts you will need to set up the MySQL database, by using our docker compose MySQL setup.
This local environment requires some manual setup. For a faster way to get started have a look at the VS Code devcontainer setup.
You need the following to be able to compile the grapher project and run the tests or use our Storybook:
All further dependencies will be automatically installed by the yarn package manager.
We recommend using the nvm Node Version manager and Visual Studio Code as the editor.
Below are steps to set up nvm and yarn. Further down are the steps to run the tests and use the storybook for development.
-
Install Homebrew first, follow the instructions here: https://brew.sh/
-
Install nvm:
brew update brew install nvm source $(brew --prefix nvm)/nvm.sh
Note: on Windows we strongly recommend using the Windows Subsystem for Linux for development as all our utility scripts are written in bash.
-
Run the following install script to set up NVM (from a WSL terminal when on windows):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
-
Clone this project if you haven't already, and switch to the project directory
-
Install Node:
nvm install
(this will pick up the right version from
.nvmrc
) -
Enable Corepack, which provides
yarn
versions:corepack enable
-
Run yarn inside the repo folder to install dependencies:
yarn
To run our test suite you first need to build the TypeScript files into JavaScript and then run jest:
-
Build JavaScript
yarn lerna run build && yarn buildTsc
-
Run jest
yarn testJest