Make sure you have relatively new nodejs/npm version (see .nvmrc
for details). To make sure that you use correct version, use:
nvm use
Fetch locked package dependencies using:
npm ci
You can run frontend connected to one of different backends, depending on your needs. After each "run" command, frontend will be available at http://localhost:3000.
Below there are described possible options.
After you execute any of them, you probably want to run also submodules
as described here. This step is optional, but most of the application's functionality relies on it.
This option requires Docker and connection to DockerHub registry. It will use touk/nussknacker
image in staging-latest
version.
npm run start:backend-staging
This option uses backend started at http://localhost:8080 . For more information how to start it, take a look at Backend instruction
npm start
You can also run frontend connected to external environment like https://demo.nussknacker.io . To do that just invoke:
npm run start:backend-demo
For more options take a look at package.json
npm test
Jest
should work out of the box, just click play button.
Background: Cypress is a framework for end-to-end frontend tests. It verifies correctness of results using captured image snapshots.
It runs tests in browser connected to our frontend application at http://localhost:3000. It uses some variables available
in cypress.env.json
like credentials.
WARNING: Image snapshots are OS and even resolution dependent! Please add image snapshots captured on unified environment.
There are a few ways to run cypress tests.
Before this option you should run backend and frontend - take a look at "Run" chapter.
After execution of:
npm run test:e2e:dev
you will see cypress devServer. It is useful to see what is done in each test, but it has some drawbacks:
- "Run all specs" option doesn't work correctly
- You can't invoke test case separately without changing file with scenario - you have to change "it" -> "xit" to exclude or "it" -> "it.only" to test separately
- Produced image snapshots are OS dependent, so you shouldn't use it for purpose of changing captured image snapshots!
This option is similar to option above, but run all tests in CLI and the same - you shouldn't use it for purpose of changing captured image snapshots!
npm run test:e2e
Thanks to Cypress Plugin you can run tests by just clicking play button. If you want to see, what cypress do, you can turn "Headed" mode on.
Just like in options above, you should run backend and frontend before and the same - you shouldn't use it for purpose of changing captured image snapshots!
This is the correct option if you want to add/modify image snapshots and make sure that it was done in deterministic way. It runs:
- NU backend and frontend in a Docker container using docker compose
- Redpanada for Kafka and SchemaRegistry support, via docker compose
- Cypress tests in Docker container
You should run once:
npm run start:backend-docker
and after that you can run multiple times:
npm run test:e2e:linux
This npm task is mainly aliases for docker compose commad to prepare the envs for cypress testing:
- runs NU backend and frontend
- runs Redpanada for Kafka and SchemaRegistry support
Behind the scenes, we clean up and run docker compose env, which is located in the client/docker-compose.yml
file.
To run cypress test in mode that would update image snapshots, use the same commands as in the option above but with :update
suffix:
npm run test:e2e:linux:update
Independent parts of application e.g. scenarios and components tabs
To render views using submodules in dev mode you need to run submodules app in dev mode as well (available on port 5001).
Assuming that core frontend is running on localhost:3000
as described here, to make it happen just:
cd ../submodules
NU_FE_CORE_URL=http://localhost:3000 npm start
WARNING: When using unified linux environment prefix npm start invocation with NU_FE_CORE_URL=http://host.docker.internal:3000 and add entry in
/etc/hosts
leading to127.0.0.1
It helps to realize what's really inside your bundle and find out what modules make up the most of it's size
npm run build-bundle-analyzer
After some changes in frontend it might be needed to rewrite captured image snapshots. The easiest way is to:
- Run cypress tests using "Run cypress tests using unified linux environment with update image snapshots mode enabled" method
- Review changes in files e.g. using Intellij Idea changes diff
- Commit changes or do fixes in scenarios.
We use react-i18next
package for internalizations. This mechanism has priority of determinining value for given key (i18next.t(key, default)
):
- label from
translations/$lng/main.json
which is served at/assets/locales/$lng/main.json
resource default
passed as an argument
File translations/$lng/main.json
is generated in prebuild
phase based on defaults. During development (start
scripts) is removed to avoid confusions.
We utilize the Mui theme for style customization. There are two themes:
- Designer client theme
- Designer components theme The components theme inherits the client theme
All Colors are stored in the modePalette, Currently, only dark mode palette support is available.