An example project that demonstrates JavaScript testing principles and practices described in the Automating CI/CD and Testing Best Practices for ArcGIS Maps SDK Projects talk at the 2024 Esri DevSummit.
This project makes use of the following:
- Create React App to setup a general framework for the application.
- Jest for the unit testing framework.
- Testing Library provides some helper functions for testing.
- Selenium to script an end-to-end test.
- ExpressJS for a simple backend to simulate server interaction.
A recording and slides of the presentation will be available at a later date. It should be uploaded to the Esri Mediaspace after the summit.
NodeJS version 20 is required to run this project. It might work on other versions.
After cloning the repository, install the dependencies by running the following in a command prompt in the base directory.
npm install
Start up the project by running the following in a command prompt:
npm run start
It will take several seconds to start up the web and backend server. The script should also open a browser window to the site, but you can view the site at http://localhost:3000.
Run the project's unit testing by entering the following in a command prompt:
npm run test
This runs the unit tests in interactive watch mode. Enter a
at the command prompt to re-run the
tests. Enter q
to exit the test runner.
You will need to install the Chrome webdriver for Selenium. This allows Selenium to control a Google Chrome browser for testing.
After installing the webdriver, enter the following in a command prompt:
node .\src\selenium_test.js
Selenium will open an instance of Chrome for testing.