Skip to content

Commit 850a1a2

Browse files
feat(dev): add Cypress and Puppeteer to GitPod (freeCodeCamp#40862)
1 parent 98de8fe commit 850a1a2

File tree

3 files changed

+105
-50
lines changed

3 files changed

+105
-50
lines changed

.gitpod.yml

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
11
image: gitpod/workspace-mongodb
22
ports:
3-
- port: 27017 # mongodb
4-
onOpen: ignore
5-
- port: 8000 # client
6-
onOpen: open-preview
7-
- port: 9228 # node debug
8-
onOpen: ignore
9-
- port: 3000 # api
10-
onOpen: ignore
11-
- port: 9229 # node debug
12-
onOpen: ignore
3+
- port: 27017 # mongodb
4+
onOpen: ignore
5+
- port: 8000 # client
6+
onOpen: open-preview
7+
- port: 9228 # node debug
8+
onOpen: ignore
9+
- port: 3000 # api
10+
onOpen: ignore
11+
- port: 9229 # node debug
12+
onOpen: ignore
1313

1414
tasks:
15-
- before: |
16-
echo '
17-
export COOKIE_DOMAIN=gitpod.io
18-
export HOME_LOCATION=$(gp url 8000)
19-
export API_LOCATION=$(gp url 3000)
20-
' >> ~/.bashrc;
21-
exit;
15+
- before: |
16+
echo '
17+
export COOKIE_DOMAIN=gitpod.io
18+
export HOME_LOCATION=$(gp url 8000)
19+
export API_LOCATION=$(gp url 3000)
20+
export CYPRESS_BASE_URL=$(gp url 8000)
21+
' >> ~/.bashrc;
22+
exit;
2223
23-
- name: db
24-
# starting mongo in background, so it doesn't block prebuilds
25-
before: >
26-
mkdir -p /workspace/data &&
27-
(mongod --dbpath /workspace/data &)
24+
- name: db
25+
# starting mongo in background, so it doesn't block prebuilds
26+
before: >
27+
mkdir -p /workspace/data &&
28+
(mongod --dbpath /workspace/data &)
2829
29-
- name: server
30-
before: export COOKIE_DOMAIN=gitpod.io && export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000)
31-
# init is not executed for prebuilt workspaces and restarts,
32-
# so we should put all the heavy initialization here
33-
init: >
34-
cp sample.env .env &&
35-
npm ci &&
36-
gp sync-done npm-ci &&
37-
gp await-port 27017 &&
38-
npm run seed &&
39-
mongo --eval "db.fsyncLock(); db.fsyncUnlock()"
40-
command: >
41-
npm run ensure-env &&
42-
gp await-port 27017 &&
43-
npm run develop:server
30+
- name: server
31+
before: export COOKIE_DOMAIN=gitpod.io && export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000) && export CYPRESS_BASE_URL=$(gp url 8000)
32+
# init is not executed for prebuilt workspaces and restarts,
33+
# so we should put all the heavy initialization here
34+
init: >
35+
cp sample.env .env &&
36+
npm ci &&
37+
gp sync-done npm-ci &&
38+
gp await-port 27017 &&
39+
npm run seed &&
40+
mongo --eval "db.fsyncLock(); db.fsyncUnlock()"
41+
command: >
42+
npm run ensure-env &&
43+
gp await-port 27017 &&
44+
npm run develop:server
4445
45-
- name: client
46-
before: export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000)
47-
init: >
48-
cd ./client &&
49-
gp sync-await npm-ci &&
50-
npm run prebuild &&
51-
npm run build:workers &&
52-
cd ..
53-
command: >
54-
gp await-port 3000 &&
55-
cd ./client &&
56-
npm run develop -- -H '0.0.0.0'
57-
openMode: split-right
46+
- name: client
47+
before: export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000) && export CYPRESS_BASE_URL=$(gp url 8000)
48+
init: >
49+
cd ./client &&
50+
gp sync-await npm-ci &&
51+
npm run prebuild &&
52+
npm run build:workers &&
53+
cd ..
54+
command: >
55+
gp await-port 3000 &&
56+
cd ./client &&
57+
npm run develop -- -H '0.0.0.0'
58+
openMode: split-right
5859

5960
github:
6061
prebuilds:

cypress-install.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
InstallCypress() {
2+
sudo apt-get update && sudo apt-get install -y \
3+
libgtk2.0-0 \
4+
libgtk-3-0 \
5+
libgbm-dev \
6+
libnotify-dev \
7+
libgconf-2-4 \
8+
libnss3 \
9+
libxss1 \
10+
libasound2 \
11+
libxtst6 \
12+
xauth \
13+
xvfb
14+
}
15+
16+
InstallPuppeteer() {
17+
sudo apt-get install -y \
18+
ca-certificates \
19+
fonts-liberation \
20+
libappindicator3-1 \
21+
libatk-bridge2.0-0 \
22+
libatk1.0-0 \
23+
libc6 \
24+
libcairo2 \
25+
libcups2 \
26+
libdbus-1-3 \
27+
libexpat1 \
28+
libfontconfig1 \
29+
libgbm1 \
30+
libgcc1 \
31+
libglib2.0-0 \
32+
libnspr4 \
33+
libpango-1.0-0 \
34+
libpangocairo-1.0-0 \
35+
libstdc++6 \
36+
libx11-6 \
37+
libx11-xcb1 \
38+
libxcb1 \
39+
libxcomposite1 \
40+
libxcursor1 \
41+
libxdamage1 \
42+
libxext6 \
43+
libxfixes3 \
44+
libxi6 \
45+
libxrandr2 \
46+
libxrender1 \
47+
lsb-release \
48+
wget \
49+
xdg-utils
50+
}
51+
52+
InstallCypress
53+
InstallPuppeteer

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"precypress": "node ./cypress-install.js",
2020
"cypress": "cypress",
2121
"cypress:install": "cypress install && echo 'for use with ./cypress-install.js'",
22+
"cypress:install-build-tools": "sh ./cypress-install.sh",
2223
"cypress:dev:run": "npm run cypress -- run",
2324
"cypress:dev:watch": "npm run cypress -- open",
2425
"cypress:prd:run": "npm run cypress -- run",

0 commit comments

Comments
 (0)