install_cypress.sh 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. ash
  3. . bash_library.sh # source bash_library.sh
  4. # install nodjs if not installed
  5. (
  6. log "Verify if nodjs is installed."
  7. dpkg -l | grep '^ii' | grep 'nodejs\s'
  8. if [ $? -eq 0 ]; then
  9. loggood "nodejs is installed."
  10. else
  11. log "Install nodejs"
  12. sudo apt install 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. npm install cypress --save-dev
  34. loggood "Cypress is now installed."
  35. )
  36. # modify cypress.json
  37. (
  38. log "Check if cypress.json exist."
  39. if [ ! -f cypress.json ]; then
  40. log "cypress.json not exist => copy from cypress.json.sample"
  41. cp cypress.json.sample cypress.json
  42. loggood "cypress.json is now available."
  43. log "Write path in cypress.json"
  44. SUBDIR=$(pwd)
  45. sed -i "s|{path_test_file}|$SUBDIR/cypress_test|g" cypress.json
  46. loggood "Path is now configured."
  47. else
  48. log "cypress.json exist => check if integrationFolder have path."
  49. if grep -q "\"integrationFolder\"\:\s\"{path_test_file}\"" cypress.json ; then
  50. log "No path => write path in cypress.json"
  51. SUBDIR=$(pwd)
  52. sed -i "s|{path_test_file}|$SUBDIR|g" cypress.json
  53. loggood "Path is now configured."
  54. else
  55. loggood "Path exist. Modify manualy if necessary."
  56. fi
  57. fi
  58. )