A TEST SCRIPT is a set of instructions (written using a scripting/programming language) that is performed on a system under test to verify that the system performs as expected. Test scripts are used in automated testing.
Sometimes, a set of instructions (written in a human language), used in manual testing, is also called a Test Script but a better term for that would be a Test Case.
In today’s world, testing can not be efficient without automation. We need automation for avoiding repetitive work, making sure that the time from development to deployment is reduced with good quality. We need good, quality automation tests, not just automation tests. We need tests which are reliable, robust, easy to code, debug, scale and can run in parallel on distributed environment.
Typically, you can do testing at any point in the development cycle, therefore you can write test cases and test scripts at any point. If you have requirements to build from, you have the building blocks for test cases in the future. If you have code, you can write test cases while the code is being built. If you already have the code, you can write tests too. Do you have data? You can write test cases. Do you have configurations? You can write test cases.