PurposeThis pilot study aims to examine the prevalence of test anxiety and its interplay with attitudes, confidence, efficacy, academic performance and socio-demographic factors within the domain of science, technology, engineering and mathematics (STEM) courses.Design/methodology/approachThe authors employed a quantitative, cross-sectional design with 549 sixth-grade students from public lower secondary schools in Prishtina, Kosovo, using the Student Attitudes Toward STEM Survey (S-STEM) for middle/high schools and the test anxiety questionnaire.FindingsOver 70% of Kosovo's sixth-grade students reported moderate to severe test anxiety. The age of students was found to be inversely related to academic performance in STEM. The father's employment was associated with favorable STEM attitudes, confidence, efficacy and academic performance. Having a personal study environment was connected with favorable STEM attitudes, confidence and efficacy in STEM, whereas access to technology was associated with positive academic performance. Test anxiety, academic performance and personal study space predicted students' attitudes, confidence and efficacy in STEM and 21st-century learning.Practical implicationsEducational institutions should prioritize student well-being. By addressing test anxiety, these institutions can create supportive learning environments that improve attitudes, confidence and efficacy in STEM fields. These efforts are crucial for STEM career development and student success in the 21st-century workforce.Originality/valueThe current study findings contribute to a deeper understanding of the factors influencing STEM student engagement and performance, highlighting the importance of addressing test anxiety for positive learning outcomes while emphasizing the need to consider socio-economic and contextual factors in education.