I tried to reproduce the problem, it seems to work just fine.
Make sure your test.js is in the same directory with your html file,
Try changing the src=“test.js” to src="./test.js" maybe…
It would be easier to help you, if you hosted your content somewhere: www.codepen.io is a good place to start.
Also, it is difficult without knowing your workspace - Where your files are (file structure), and what tools you are using to work with HTML and Javascript.
My recommendation is to put your work in a CodePen, and share the link with us, here.