install_cypress.sh 1.8KB

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