Skip to content

Commit 48cffc5

Browse files
committed
chore: migrate over more projects
1 parent 2cf8484 commit 48cffc5

File tree

230 files changed

+47972
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+47972
-62
lines changed
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 2.1
2+
orbs:
3+
cypress: cypress-io/cypress@1.29.0
4+
5+
workflows:
6+
build:
7+
jobs:
8+
- cypress/run:
9+
post-steps:
10+
- run:
11+
when: always
12+
name: Merge MochaAwesome Reports
13+
command: npx mochawesome-merge cypress/reports/mocha/*.json > mochareports/report.json
14+
- run:
15+
when: always
16+
name: Create mochawesome html report
17+
command: npx marge mochareports/*.json -f report -o mochareports
18+
- run:
19+
when: always
20+
name: Slack report
21+
command: npx cypress-slack-reporter --verbose
22+
- store_artifacts:
23+
path: mochareports
24+
- store_test_results:
25+
path: cypress/reports
26+
27+
# nightly:
28+
# triggers: #use the triggers key to indicate a scheduled build
29+
# - schedule:
30+
# cron: "0 0 * * *" # use cron syntax to set the schedule
31+
# filters:
32+
# branches:
33+
# only:
34+
# - add-cypress
35+
jobs:
36+
- cypress/run:
37+
post-steps:
38+
- run:
39+
when: always
40+
name: Merge MochaAwesome Reports
41+
command: npx mochawesome-merge cypress/reports/mocha/*.json > mochareports/report.json
42+
- run:
43+
when: always
44+
name: Create mochawesome html report
45+
command: npx marge mochareports/*.json -f report -o mochareports
46+
- run:
47+
when: always
48+
name: Slack report
49+
command: npx cypress-slack-reporter --verbose
50+
- store_artifacts:
51+
path: mochareports
52+
- store_test_results:
53+
path: cypress/results
54+

cypress-circleci-orb/.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
cypress/.env
3+
cypress/screenshots
4+
cypress/videos
5+
cypress/reports
6+
.git
7+
.cache
8+
**/.DS_Store
9+
.scannerwork/

cypress-circleci-orb/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
**/.DS_Store
3+
.scannerwork/
4+
logs
5+
cypress/.env
6+
cypress/videos
7+
cypress/screenshots
8+
cypress/reports

cypress-circleci-orb/Dockerfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM cypress/base:14
2+
3+
ARG FIREFOX_VERSION=57.0.2
4+
5+
USER root
6+
7+
RUN node --version
8+
RUN echo "force new chrome here"
9+
10+
# install Chromebrowser
11+
RUN \
12+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
13+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \
14+
apt-get update && \
15+
apt-get install -y dbus-x11 google-chrome-stable && \
16+
rm -rf /var/lib/apt/lists/*
17+
18+
# "fake" dbus address to prevent errors
19+
# https://github.com/SeleniumHQ/docker-selenium/issues/87
20+
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
21+
22+
# install Firefox browser
23+
RUN wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 \
24+
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 \
25+
&& rm /tmp/firefox.tar.bz2 \
26+
&& ln -fs /opt/firefox/firefox /usr/bin/firefox
27+
28+
# Add zip utility - it comes in very handy
29+
RUN apt-get update && apt-get install -y zip
30+
31+
# versions of local tools
32+
RUN node -v
33+
RUN npm -v
34+
RUN yarn -v
35+
RUN google-chrome --version
36+
RUN firefox --version
37+
RUN zip --version
38+
RUN git --version
39+
40+
# a few environment variables to make NPM installs easier
41+
# good colors for most applications
42+
ENV TERM xterm
43+
# avoid million NPM install messages
44+
ENV npm_config_loglevel warn
45+
# allow installing when the main user is root
46+
ENV npm_config_unsafe_perm true
47+
# copy our files into our container
48+
WORKDIR /app
49+
50+
COPY / /app
51+
52+
RUN npm install

cypress-circleci-orb/Makefile

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
DOCKERIMGNAME=cypresstestdocker
2+
DOCKERRUNCMD=docker-compose run --rm $(DOCKERIMGNAME)
3+
CYPRESSRUNCMD=npx cypress run
4+
CYPRESSGUICMD=npx cypress open
5+
6+
test:
7+
$(CYPRESSRUNCMD)
8+
9+
test-gui:
10+
$(CYPRESSGUICMD)
11+
12+
test-local:
13+
$(CYPRESSRUNCMD) --env configFile=development
14+
15+
test-qa:
16+
$(CYPRESSRUNCMD) --env configFile=qa
17+
18+
test-staging:
19+
$(CYPRESSRUNCMD) --env configFile=staging
20+
21+
test-production:
22+
$(CYPRESSRUNCMD) --env configFile=production
23+
24+
test-local-gui:
25+
$(CYPRESSGUICMD) --env configFile=development
26+
27+
test-qa-gui:
28+
$(CYPRESSGUICMD) --env configFile=qa
29+
30+
test-record:
31+
$(CYPRESSRUNCMD) --record
32+
33+
combine-reports:
34+
npx mochawesome-merge cypress/reports/mocha/*.json > mochareports/report-$$(date +'%Y%m%d-%H%M%S').json
35+
36+
generate-report:
37+
npx marge mochareports/*.json -f report-$$(date +'%Y%m%d-%H%M%S') -o mochareports
38+
39+
slack-alert:
40+
npx cypress-slack-reporter --logger
41+
42+
docker-build:
43+
docker build . -t $(DOCKERIMGNAME)
44+
45+
docker-bash:
46+
$(DOCKERRUNCMD) /bin/bash
47+
48+
docker-test:
49+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD)
50+
51+
docker-test-local:
52+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD) --env configFile=development
53+
54+
docker-test-qa:
55+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD) --env configFile=qa
56+
57+
docker-test-staging:
58+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD) --env configFile=staging
59+
60+
docker-test-production:
61+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD) --env configFile=production
62+
63+
docker-test-record:
64+
$(DOCKERRUNCMD) $(CYPRESSRUNCMD) --record

cypress-circleci-orb/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# cypress-circleorbtest
2+
3+
An example repo to show
4+
5+
- CircleCI integration with Cypress Orbs
6+
- Mochawesome for fancy HTML reporting with `mochawesome`
7+
- Mochawesome report merging with `mochawesome-merge`
8+
- Slack reporting with `cypress-slack-reporter`
9+
10+
Ensure post steps are set to run always, otherwise they will not run when a Cypress test fails
11+
12+
```
13+
version: 2.1
14+
orbs:
15+
cypress: cypress-io/cypress@1.7.0
16+
17+
workflows:
18+
build:
19+
jobs:
20+
- cypress/run:
21+
post-steps:
22+
- run:
23+
when: always
24+
name: Merge MochaAwesome Reports
25+
command: npx mochawesome-merge cypress/reports/mocha/*.json > mochareports/report.json
26+
- run:
27+
when: always
28+
name: Create mochawesome html report
29+
command: npx marge mochareports/*.json -f report -o mochareports
30+
- run:
31+
when: always
32+
name: Slack report
33+
command: npx cypress-slack-reporter --verbose
34+
- store_artifacts:
35+
path: mochareports
36+
- store_test_results:
37+
path: cypress/reports
38+
```
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
appName: 'cypress-docker',
3+
showLogs: false,
4+
isDisabled: true,
5+
batchName: 'test batch'
6+
// to enable, remove comments from support/index.js & plugins/index.js
7+
// there is an error in the afterhook, when isDisabled is set to true!
8+
// Error: Cannot read property 'error' of undefined
9+
// Because this error occurred during a 'after all' hook we are skipping all of the remaining tests.
10+
// at Context.send.then.resp (https://applitools.com/__cypress/tests?p=cypress/support/index.js-695:1742:15)
11+
}

cypress-circleci-orb/cypress.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"baseUrl": "https://the-internet.herokuapp.com",
3+
"reporter": "cypress-multi-reporters",
4+
"reporterOptions": {
5+
"configFile": "reporterOpts.json"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": ""
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://the-internet.herokuapp.com"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://the-internet.herokuapp.com"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://the-internet.herokuapp.com"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>cypress-testing-library</title>
8+
<style>
9+
blockquote {
10+
margin: 0;
11+
border-left: 4px solid grey;
12+
padding-left: 10px;
13+
color: grey;
14+
}
15+
section {
16+
padding: 10px;
17+
}
18+
</style>
19+
</head>
20+
<body>
21+
<blockquote>
22+
No auto-reload after changing this static HTML markup:
23+
click <span title="Run All Tests"></span> Run All Tests.
24+
</blockquote>
25+
<section>
26+
<h2>getByPlaceholderText</h2>
27+
<input type="text" placeholder="Placeholder Text" />
28+
</section>
29+
<section>
30+
<h2>getByText</h2>
31+
<button onclick="this.innerText = 'Button Clicked'">Button Text</button>
32+
<div id="nested">
33+
<h3>getByText within</h3>
34+
<button onclick="this.innerText = 'Button Clicked'">Button Text</button>
35+
</div>
36+
</section>
37+
<section>
38+
<h2>getByLabelText</h2>
39+
<label for="input-labelled-by-id">Label For Input Labelled By Id</label>
40+
<input type="text" placeholder="Input Labelled By Id" id="input-labelled-by-id" />
41+
</section>
42+
<section>
43+
<h2>getByAltText</h2>
44+
<img
45+
src="data:image/png;base64,"
46+
alt="Image Alt Text"
47+
onclick="this.style.border = '5px solid red'"
48+
/>
49+
</section>
50+
<section>
51+
<h2>getByTestId</h2>
52+
<img
53+
data-testid="image-with-random-alt-tag"
54+
src="data:image/png;base64,"
55+
onclick="this.style.border = '5px solid red'"
56+
/>
57+
</section>
58+
<section>
59+
<h2>getAllByText</h2>
60+
<button onclick="this.innerText = 'Jackie Kicked'">Jackie Chan 1</button>
61+
<button onclick="this.innerText = 'Jackie Kicked'">Jackie Chan 2</button>
62+
</section>
63+
<!-- Prettier unindents the script tag below -->
64+
<script>
65+
document
66+
.querySelector('[data-testid="image-with-random-alt-tag"]')
67+
.setAttribute('alt', 'Image Random Alt Text ' + Math.random())
68+
</script>
69+
</body>
70+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
import { login } from '../../../support/pageObjects/login.page';
3+
4+
describe('Logging In - HTML Web Form - The Internet', () => {
5+
context('Unauthorized', () => {
6+
it('User denied access with invalid details', () => {
7+
login.visit()
8+
login.username.type('invalidUser')
9+
login.password.type('invalidPassword{enter}')
10+
login.errorMsg.contains('Your username is invalid!')
11+
login.logOutButton.should('not.exist')
12+
})
13+
it('User granted access with valid details', () => {
14+
login.visit()
15+
login.username.type('tomsmith')
16+
login.password.type('SuperSecretPassword!{enter}')
17+
login.successMsg.contains('You logged into a secure area!')
18+
login.logOutButton.should('exist')
19+
})
20+
})
21+
})

0 commit comments

Comments
 (0)