Guide on Testing Child Processes with Mocked Dependencies in Elixir

78
clicks
Guide on Testing Child Processes with Mocked Dependencies in Elixir

Source: mirego.com

Type: Post

The article addresses common problems faced when testing child processes with mocked dependencies in Elixir. Benoit Ducharme explains that issues such as the `UndefinedFunctionError` and `Mox.UnexpectedCallError` occur because the process starts before the mock is defined or because the expectations are process-based and the child process does not access the mock. The piece offers a solution: injecting the process only in non-test environments and configuring tests to allow access to the mock using Mox in global mode. Specific code snippets and configuration changes are provided to illustrate the solution.

© HashMerge 2024