install_cypress.sh 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. . bash_library.sh # source bash_library.sh
  3. # install nodjs if not installed
  4. (
  5. log "Verify if nodjs is installed."
  6. dpkg -l | grep '^ii' | grep 'nodejs\s'
  7. if [ $? -eq 0 ]; then
  8. loggood "nodejs is installed."
  9. else
  10. log "Install nodejs"
  11. sudo apt install curl
  12. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  13. sudo apt install -y nodejs
  14. loggood "nodejs is now installed."
  15. fi
  16. )
  17. # install Cypress
  18. log "Go to functionnal_tests subdir.."
  19. cd functionnal_tests || exit 1;
  20. (
  21. ACTUALDIR=$(pwd)
  22. loggood "Your are now here: \"$ACTUALDIR\""
  23. log "Check if package.json exist."
  24. if [ ! -f package.json ]; then
  25. log "package.json not exist => run npm init"
  26. npm init -y
  27. loggood "npm init finished => package.json is now created."
  28. else
  29. loggood "package.json exist."
  30. fi
  31. log "Install cypress."
  32. npm install cypress --save-dev
  33. loggood "Cypress is now installed."
  34. )
  35. # modify cypress.json
  36. (
  37. log "Check if cypress.json exist."
  38. if [ ! -f cypress.json ]; then
  39. log "cypress.json not exist => copy from cypress.json.sample"
  40. cp cypress.json.sample cypress.json
  41. loggood "cypress.json is now available."
  42. log "Write path in cypress.json"
  43. SUBDIR=$(pwd)
  44. sed -i "s|{path_test_file}|$SUBDIR/cypress_test|g" cypress.json
  45. loggood "Path is now configured."
  46. else
  47. log "cypress.json exist => check if integrationFolder have path."
  48. if grep -q "\"integrationFolder\"\:\s\"{path_test_file}\"" cypress.json ; then
  49. log "No path => write path in cypress.json"
  50. SUBDIR=$(pwd)
  51. sed -i "s|{path_test_file}|$SUBDIR|g" cypress.json
  52. loggood "Path is now configured."
  53. else
  54. loggood "Path exist. Modify manualy if necessary."
  55. fi
  56. fi
  57. )