testing/behavioural/README.md
In this project ag-grid is tested as a black box, we test the grid at the edges, instantiating the full grid to test complex behaviours and features.
The unit under test here is a behaviour, not a function, a class, a method, or a file.
Mocking is to be avoided as much as possible here, and the use of fakes is preferred (for example this project uses fake DOM).
To execute all tests, run from the repo root:
./behave.sh
To execute tests matching a file pattern:
./behave.sh "filename"
To run in watch mode:
./behave.sh --watch
To overwrite the snapshots for snapshot tests:
./behave.sh --update
When diagram formatting or grid behaviour changes, you can automatically update all GridRows inline
snapshots (the template literals passed to .check()):
# Update all GridRows snapshots
./behave.sh --update-grid-rows
# Update snapshots in matching test files only
./behave.sh --update-grid-rows "cell-editing"
# Dry-run: show what would change without writing files
./behave.sh --update-grid-rows=dry
# Equivalent env var form
UPDATE_GRID_ROWS_SNAPSHOTS=1 ./behave.sh
UPDATE_GRID_ROWS_SNAPSHOTS=dry ./behave.sh
The updater uses TypeScript's parser to locate .check() calls and precisely rewrite the template
literal argument, preserving surrounding code and indentation. It handles direct inline template
literals, variable references (const x = \...`; gridRows.check(x)), and tagged templates. Dynamic strings with ${}` interpolation are skipped with a warning.
To execute benchmarks:
nx run ag-behavioural-testing:benchmark
To execute benchmarks on a single file:
nx run ag-behavioural-testing:benchmark -- src/tree-data/datapath/benchmarks/tree-data-path.bench.ts