To determine the functionality of a private method, you may need to consider some hacking techniques to bypass its restricted access. Refer to Makoto's comment for insights on this approach.
Typically, testing a private method involves evaluating the public method that invokes it within your class. This indicates that the private method will eventually be executed as part of the class workflow. For instance:
export class Example 1 {
constructor() {}
public foo() {
this.bar()
}
private bar() {
... perform amazing tasks ...
}
}
In this scenario, testing the foo() method is essential to ensure the desired outcome, which encompasses the functionality encapsulated in bar().
If you aim to confirm the invocation of data.fetDetails, consider employing a spy technique and assessing the equivalent operation to foo in your implementation.