How about modifying the "./test-install.sh" so that it creates some sort of a stamp file on the first run and use that file to detect whether the initialisation was already performed?

You can make the detection logic more robust by comparing the write time of the stamp file with something else (e.g. package.json), or even writing hash of dependencies into this file, so that you can detect changes that require re-initialisation.