To begin with you should use `spawn` to run your script, and I'm not certain the tilde construct will be interpreted by expect.
spawn /bin/bash /home/username/test.sh
You should have error messages when this happens, you should add the to your question if you do not understand them.