Browse Source

fix for script install cypress

philippe 6 years ago
parent
commit
47b8305ce6
3 changed files with 46 additions and 5 deletions
  1. 5 0
      bash_library.sh
  2. 6 0
      functionnal_tests/cypress.json.sample
  3. 35 5
      install_cypress.sh

+ 5 - 0
bash_library.sh View File

2
 
2
 
3
 YELLOW='\033[1;33m'
3
 YELLOW='\033[1;33m'
4
 BROWN='\033[0;33m'
4
 BROWN='\033[0;33m'
5
+GREEN='\033[1;32m'
5
 NC='\033[0m' # No Color
6
 NC='\033[0m' # No Color
6
 
7
 
7
 function log {
8
 function log {
8
     echo -e "\n${YELLOW}[$(date +'%H:%M:%S')]${BROWN} $ $1${NC}"
9
     echo -e "\n${YELLOW}[$(date +'%H:%M:%S')]${BROWN} $ $1${NC}"
9
 }
10
 }
11
+
12
+function loggood {
13
+    echo -e "\n${YELLOW}[$(date +'%H:%M:%S')]${GREEN} $ $1${NC}"
14
+} 

+ 6 - 0
functionnal_tests/cypress.json.sample View File

1
+{
2
+  "baseUrl": "http://localhost:6543",
3
+  "viewportWidth": 1280,
4
+  "viewportHeight": 1024,
5
+  "integrationFolder": "{path_test_file}"
6
+}

+ 35 - 5
install_cypress.sh View File

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