Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing unit tests for Javascript code #766

Open
marco-brandizi opened this issue Jun 22, 2023 · 1 comment
Open

Introducing unit tests for Javascript code #766

marco-brandizi opened this issue Jun 22, 2023 · 1 comment
Assignees
Labels
chore/infrastructure continuous integration Related to building and CI systems/operations project:client Related to the client/front-end war. UI-testing Tickets relating to testing frontend - Selenium and Unit tests/ reminders to run

Comments

@marco-brandizi
Copy link
Member

marco-brandizi commented Jun 22, 2023

This is a smaller sub-task of #733

I have some (semi) automated tests for the UI Javascript here. These tests are pretty useful for the most complicated parts and we should aim at introducing some proper testing framework, as well as automating tests execution during the application build cycle.

For the former aim, there are a lot of test libraries and hence we should first evaluate the one we want to use. From what I see, Jest is a popular and feature-rich one, but I'm open to discussion.

After that, we should start from the above-mentioned tests, convert them into the chosen test library and arrange things so that we can run the tests from the command line (presumably, assuming NodeJS is installed and using it) have some report (ideally, on file, but standard output is OK too) and have the corresponding command exiting with a non-zero code in case of failures, so that we have a mean to stop the build when needed.

In detail, this implies test .js files, which Node.js can load, see and execute imports about the test framework, see and exec other imports about the code to be tested and then run the unit tests in the loaded files. Such test files should stay separated from the files that are deployed with the web application (if we want to follow Maven conventions, they would be in client-base/src/test/javascript).

Once we have this, integrating this into the Maven build is quite simple and I can work on that.

Note that, for the moment I'm only considering those cases that can be automated and don't require any browser. Testing UI components is a different and more complicated matter.

Also, if we start doing this in the current Knetminer, it's some useful experience for the new architecture.

@marco-brandizi marco-brandizi added chore/infrastructure project:client Related to the client/front-end war. continuous integration Related to building and CI systems/operations UI-testing Tickets relating to testing frontend - Selenium and Unit tests/ reminders to run labels Jun 22, 2023
@marco-brandizi
Copy link
Member Author

marco-brandizi commented Jun 22, 2023

I've added @Arnedeklerk, in case he has some experience with Js testing or wants to look into stuff like test frameworks, Selenium etc.

I'll also add some doc to the manual tests repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore/infrastructure continuous integration Related to building and CI systems/operations project:client Related to the client/front-end war. UI-testing Tickets relating to testing frontend - Selenium and Unit tests/ reminders to run
Projects
None yet
Development

No branches or pull requests

3 participants