The Sobel test can help do the mediation test. This test calculates the percentage of the total effect that is mediated and the ratio of the indirect to the direct effect. You may also read research by Baron and Kenny. It listed out a series of four required steps to follow when running a mediational hypothesis (See Baron RM and Kenny DA, 1986).
Baron RM and Kenny DA, The moderator-mediator variable distinction in social psychological research: conceptual, strategic, and statistical considerations. J Personal Soc Psychol. 1986;51:1173–82.
Researchers often test whether there is complete or partial mediation by testing whether the c′ coefficient is statistically significant, which is a test of whether the association between the independent and dependent variable is completely accounted for by the mediator (see James et al. 2006). If the c′ coefficient is statistically significant and there is significant mediation, then there is evidence for partial mediation. Because psychological behaviors have a variety of causes, it is often unrealistic to expect that a single mediator would be explained completely by an independent variable to dependent variable relation (See Judd & Kenny 1981a).
James LR, Mulaik SA, Brett JM. A tale of two methods. Org Res Methodol. 2006;9:233–44.
Judd CM, Kenny DA. Estimating the Effects of Social Interventions. Cambridge, UK: Cambridge Univ Press; 1981a.
For Sobel test calculations, see https://quantpsy.org/sobel/sobel.htm which provides a step-by-step guide.
Two papers below where the Sobel test is used to measure mediation in similar situations: