|
2 | 2 |
|
3 | 3 | cd lighthouse-cli/test/fixtures && python -m SimpleHTTPServer 9999 & |
4 | 4 |
|
5 | | -if [[ $(node -v) =~ ^v4.* ]]; then |
6 | | - node --harmony lighthouse-cli/index.js http://localhost:9999/online-only.html > results |
7 | | -else |
8 | | - ./lighthouse-cli/index.js http://localhost:9999/online-only.html > results |
| 5 | +NODE=$([ $(node -v | grep -E "v4") ] && echo "node --harmony" || echo "node") |
| 6 | +offline200result="URL responds with a 200 when offline" |
| 7 | + |
| 8 | + |
| 9 | +$NODE lighthouse-cli http://localhost:9999/online-only.html > results |
| 10 | + |
| 11 | +# test that we have results |
| 12 | +if ! grep -q "$offline200result" results; then |
| 13 | + echo "Fail! Lighthouse run didn't create a result file" |
| 14 | + exit 1 |
9 | 15 | fi |
10 | 16 |
|
11 | | -if ! grep -q "URL responds with a 200 when offline: false" results; then |
| 17 | +# test that we have a meta viewport defined in the static page |
| 18 | +if ! grep -q "HTML has a viewport <meta>: true" results; then |
| 19 | + echo "Fail! Meta viewort not detected in the page" |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +# test static page which should fail the offline test |
| 24 | +if ! grep -q "$offline200result: false" results; then |
12 | 25 | echo "Fail! online only site worked while offline" |
13 | 26 | cat results |
14 | 27 | exit 1 |
15 | 28 | fi |
16 | 29 |
|
17 | 30 | sleep 5s |
18 | 31 |
|
19 | | -if [[ $(node -v) =~ ^v4.* ]]; then |
20 | | - node --harmony lighthouse-cli/index.js https://www.moji-brush.com > results |
21 | | -else |
22 | | - ./lighthouse-cli/index.js https://www.moji-brush.com > results |
23 | | -fi |
| 32 | +# test mojibrush which should pass the offline test |
| 33 | +$NODE lighthouse-cli https://www.moji-brush.com > results |
24 | 34 |
|
25 | | -if ! grep -q "URL responds with a 200 when offline: true" results; then |
| 35 | +if ! grep -q "$offline200result: true" results; then |
26 | 36 | echo "Fail! offline ready site did not work while offline" |
27 | 37 | cat results |
28 | 38 | exit 1 |
|
0 commit comments