For example, if a person is affected by abuse, bullying, neglect, or some other stressor or trauma, then how much of an effect would that have on their test score?
Short answer: The effect of stress and trauma on IQ varies significantly according to type and severity, but is overall fairly low relative to normal variation in scores.
... test-takers may have varying scores when taking the same test on differing occasions, and may have varying scores when taking different IQ tests at the same age. ... For modern tests, the confidence interval can be approximately 10 points ...
Additionally, particularly low or high IQ scores are less reliable than median scores. Nonetheless:
Outside influences such as low motivation or high anxiety can occasionally lower a person's IQ test score.
So, up to approximately 10 IQ points difference in scores can be accounted for by measurement error and performance variability, but stressors can potentially result in larger differences.
Despite the broad scope of the question, I was not able to find any recent dedicated literature reviews on the effects of any particular type of stress or trauma on IQ, so conclusions are based on a sample of recent available studies.
Marcus Jenkins et al (2013) looked at the effects of family stress on child IQ:
... we identified four subconstructs that capture family stress: Marital conflict, parenting stress, depressive symptoms and maternal history of psychiatric disorders. ... None of the family stress components mediated the effect of the SES components on child IQ.
... a child experiencing both violence exposure and trauma-related distress at or above the 90th percentile would be expected to have a 7.5-point (SD, 0.5) decrement in IQ ...
Butler et al (2018) found similar effects on adolescent IQ. However, Saigh et al (2006) and DePrince, Weinzierl, & Combs (2009) also looked at the impact of violence and trauma on child IQ, but found no effect.
Viezel, Freer, & Castillo (2015) looked at the effect of abuse and neglect, and found an approximately 5-point decrement in child IQ, while Doerfler, Toscano, & Connor (2008) looked at the effect of abuse on adolescent IQ:
For Performance IQ or Full Scale IQ scores, there were no significant main effects for gender or abuse experience.
Kira et al (2012), Kira et al (2012), and Kira et al (2014) looked at the effect of a variety of different stressors and traumas - including abuse, bullying, abandonment, and violence - on adolescent IQ in 2 vulnerable sub-groups:
Our findings support the hypothesis that different trauma types have different influences, some positive and some negative. ... In conclusion, trauma type differentially impacts IQ.
However, the effect of stress on overall IQ was small (r<0.15).
Note that many studies found significant effects of stress and trauma on IQ sub-tests and sub-components, though overall IQ was often not significantly affected. Note also that ethical conduct makes stress and trauma difficult to manipulate experimentally, so these studies are largely retrospective, or at best prospective, but not randomized controlled studies. Thus, study quality is an issue, making conclusions tentative - in particular, the direction of causality is not always entirely clear.
Stress will certainly affect your test performance and cognition, see Lupien 2007.
It might be a bit hard to measure this in an experiment, as the same individuals have to take the test with and without stress. But then you have to control for some learned effect, second time the test might be easier.