Skip to content

Commit 9006a68

Browse files
committed
test: add end-to-end tests
1 parent 88ccbc6 commit 9006a68

File tree

6 files changed

+4358
-0
lines changed

6 files changed

+4358
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: End-to-end tests
2+
on:
3+
push:
4+
branches: "*"
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-18.04
9+
10+
env:
11+
FFMPEG_PATH: /usr/bin/ffmpeg # for recording video
12+
QAW_ARTIFACT_PATH: ${{ github.workspace }}/artifacts # save video and logs
13+
14+
steps:
15+
- name: Install browser dependencies
16+
run: |
17+
sudo apt update
18+
# chromium dependencies
19+
sudo apt-get install libgbm1
20+
# webkit dependencies
21+
sudo apt-get install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libvpx5 libxslt1.1
22+
# ffmpeg
23+
sudo apt-get install -y ffmpeg
24+
25+
- uses: actions/setup-node@v1
26+
27+
- name: Add yarn global bin to path
28+
run: echo "::add-path::$(yarn global bin)"
29+
30+
- uses: actions/checkout@v2
31+
with:
32+
path: ./vuepress
33+
34+
- name: Install and register VuePress
35+
run: |
36+
yarn
37+
yarn register-vuepress
38+
yarn tsc
39+
working-directory: ./vuepress
40+
41+
- name: Install end-to-end test dependencies
42+
run: yarn
43+
working-directory: ./vuepress/__e2e__
44+
45+
- name: Create test project
46+
run: |
47+
mkdir test_project
48+
cd test_project
49+
yarn init -y
50+
yarn link vuepress
51+
echo '# Hello VuePress' > README.md
52+
53+
- name: Run VuePress
54+
run: vuepress dev &
55+
working-directory: ./test_project
56+
57+
- name: Test first page
58+
run: npx qawolf test --all-browsers --headless initialSetup
59+
working-directory: ./vuepress/__e2e__
60+
61+
- name: Add another page
62+
run: |
63+
mkdir get_started
64+
echo '# Get Started' > get_started/README.md
65+
echo '[Get Started](/get_started/)' >> README.md
66+
working-directory: ./test_project
67+
68+
- name: Test additional page
69+
run: npx qawolf test --all-browsers --headless linkAndSearch
70+
working-directory: ./vuepress/__e2e__
71+
72+
- name: Upload artifacts
73+
if: always()
74+
uses: actions/upload-artifact@master
75+
with:
76+
name: e2e
77+
path: ${{ github.workspace }}/artifacts

__e2e__/initialSetup.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const qawolf = require('qawolf')
2+
3+
let browser
4+
let page
5+
6+
/* eslint-env jest */
7+
beforeAll(async () => {
8+
browser = await qawolf.launch()
9+
const context = await browser.newContext()
10+
await qawolf.register(context)
11+
page = await context.newPage()
12+
})
13+
14+
afterAll(async () => {
15+
await qawolf.stopVideos()
16+
await browser.close()
17+
})
18+
19+
test('initialSetup', async () => {
20+
await page.goto('http://localhost:8080/')
21+
22+
// test will fail if the header never appears
23+
await page.waitFor('h1#hello-vuepress')
24+
})

__e2e__/linkAndSearch.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const qawolf = require('qawolf')
2+
3+
let browser
4+
let page
5+
6+
/* eslint-env jest */
7+
beforeAll(async () => {
8+
browser = await qawolf.launch()
9+
const context = await browser.newContext()
10+
await qawolf.register(context)
11+
page = await context.newPage()
12+
})
13+
14+
afterAll(async () => {
15+
await qawolf.stopVideos()
16+
await browser.close()
17+
})
18+
19+
test('linkAndSearch', async () => {
20+
await page.goto('http://localhost:8080/')
21+
await page.click('text="Get Started"')
22+
23+
// test will fail if header never appears
24+
await page.waitFor('h1#get-started')
25+
26+
await page.type('[aria-label="Search"]', 'hello')
27+
await page.click('ul a[href="/"]')
28+
29+
// test will fail if header never appears
30+
await page.waitFor('h1#hello-vuepress')
31+
})

__e2e__/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "e2e",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"main": "index.js",
6+
"devDependencies": {
7+
"jest": "~25.1.0",
8+
"playwright": "~0.12.1",
9+
"qawolf": "~0.12.4"
10+
}
11+
}

__e2e__/qawolf.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
config: '{}',
3+
rootDir: '.',
4+
testTimeout: 60000,
5+
useTypeScript: true
6+
}

0 commit comments

Comments
 (0)