How shared workers work in AVA
mainShared workers allow a program to run in a worker thread within AVA's main process, enabling communication with code running in individual test workers. This is useful for managing shared resources (like database connections or port locking) across all test files in a run.
Key characteristics:
- Persistence: In watch mode, shared workers remain loaded across runs.
- Resource Management: They provide opportunities to set up resources before tests start and clean them up after.
- Communication: Test workers and the shared worker communicate via a versioned protocol using message passing.