Structure your code differently. Have your main code work as a framework for what they are doing -> have a ToImplement class(es) in a seperate file which you will refrence in tests (maybe not even directly, you could still run tests against the index.js stuff). The class under test can have some public methods or you can make students add them, as the tests will fail otherwise. You can then mess with index.js if you miss anything and they could then just pull.
If you have some code already implemented for them to use, keep it in a seperate file and make them import it or import it yourself for them, but you have to keep a clear teacher/student seperation.
If they fool around with your code for some reason, have a checkout script for your files, and I think that will solve most of your issues.