The package is part of the viewer-components-react monorepo - please make sure to have a look at repository's contribution guidelines.
Set up steps:
pnpm installin repository root to install dependencies.- (optional)
pnpm cleanto clear previous build artifacts. pnpm build --scope property-grid-reactto build the package.npm run testin package root to run its unit tests.
Often, you'll want to see the widget in a running application. For that, we have a test viewer application. To start it in watch mode:
- Follow steps 1-3 from above.
pnpm build --to test-viewerto build the viewer an all its dependencies.cd apps/test-viewerto navigate to the viewer app directory.- Fill the details in
.envfile in test viewer directory. See.env.templatefor an example. npm run start:devto run the viewer.
We have two sets of tests - unit tests and end-to-end ones.
Purpose of these tests is to make sure each unit (class, function, component, etc.) works according to its specification.
Relevant scripts:
- Run:
npm run test. - Measure source coverage:
npm run cover.
Purpose of end-to-end tests is to make sure the widget and its features work as a whole, taking into account all the dependencies. This is achieved by the test runner (playwright) starting the test-viewer and simulating user actions to test various features of the widget. In addition, our tests take widget screenshots in various situations to ensure we capture all styling changes.
Before running e2e tests, test viewer must be built using QA configuration:
- Set up
.envintest-viewerdirectory to use QA configuration. See.env.templatefor an example. - Run
npm run distintest-viewerdirectory to create a production build of the app.
Relevant scripts:
- Run locally:
npm run test:e2e:local. - Debug locally:
npm run test:e2e:debug. - Run in a Docker container:
npm run test:e2e. Note: This requires Docker to be running on your machine.
Running the tests in a non-CI environment automatically updates all the screenshots - please make sure the visual changes are expected and valid in case the screenshots change. In a CI environment the tests fail if any mismatches are detected.
Note: The screenshots might have slight visual differences between platforms. To ensure we always get consistent results, the screenshots should always be generated by running the tests in a docker container (npm run test:e2e script).
Another note: E2E tests are run against a specific iModel in our QA environment. Contact repository maintainers to get access to that iModel, if needed. The required credentials must be specified in .env.e2e at the package root - see .env.e2e.template for an example.
Vitest does not provide a practical way to launch and debug a specific test via launch.json. Instead, use the Vitest extension (vitest.explorer) for VS Code. It integrates with the Test Explorer panel, allowing you to run and debug individual tests directly from the editor with breakpoints.