Make sure you've these installed :
rustup --version
rustc --version
cargo --version
solana --version
Now, run the following commands :
solana config set --url devnet
cd solana-programs/
npm i
yarn add ts-mocha
Finally, to run :
anchor test