In the category of $\mathbb{Z}$-modules, there exists a module $A$---for instance $\bigoplus_{k=2}^\infty \mathbb{Z}/k\mathbb{Z}$---such that a $\mathbb{Z}$-module $B$ is injective iff $\operatorname{Ext}^1_\mathbb{Z}(A,B)=0$.

Does this hold if $\mathbb{Z}$ is replaced with an arbitrary (unital) ring $R$? If not, what are some sufficient conditions on $R$ for this to hold?

As a comment, note that this is equivalent to requiring the existance of a family $\{A_j\}_{j\in J}$ of $R$-modules indexed by some *set* $J$ such that an $R$-module $B$ is injective iff $\operatorname{Ext}^1_R(A_j,B)=0$ for all $j\in J$: This is clearly implied by the original statement. To get the other direction, set $A:=\bigoplus_{j\in J} A_j$. Then $$\operatorname{Ext}^1_R(A,B)=\prod_{j\in J} \operatorname{Ext}^1_R(A_j, B)=0$$ since each component is $0$.