Skip to content

Commit 8538f0b

Browse files
authored
test: run e2e tests in chrome and firefox (#3)
1 parent 572ab92 commit 8538f0b

File tree

4 files changed

+220
-19
lines changed

4 files changed

+220
-19
lines changed

.github/workflows/e2e.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: e2e
16+
on:
17+
push:
18+
schedule:
19+
- cron: "0 12 * * *"
20+
jobs:
21+
chrome:
22+
runs-on: ubuntu-latest
23+
services:
24+
hub:
25+
image: selenium/standalone-chrome
26+
volumes:
27+
- ${{ github.workspace }}:${{ github.workspace }}
28+
ports:
29+
- 4444:4444
30+
steps:
31+
- uses: actions/checkout@v2
32+
- run: npm i
33+
- run: npm run test:e2e
34+
env:
35+
GOOGLE_MAPS_API_KEY: ${{ secrets.SYNCED_GOOGLE_MAPS_API_KEY_WEB }}
36+
firefox:
37+
runs-on: ubuntu-latest
38+
services:
39+
hub:
40+
image: selenium/standalone-firefox
41+
volumes:
42+
- ${{ github.workspace }}:${{ github.workspace }}
43+
ports:
44+
- 4444:4444
45+
steps:
46+
- uses: actions/checkout@v2
47+
- run: npm i
48+
- run: npm run test:e2e
49+
env:
50+
GOOGLE_MAPS_API_KEY: ${{ secrets.SYNCED_GOOGLE_MAPS_API_KEY_WEB }}
51+
BROWSER: firefox

e2e/selenium.test.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,36 @@ import webdriver from "selenium-webdriver";
2020
let driver: webdriver.WebDriver;
2121

2222
beforeAll(async () => {
23-
let capabilities: webdriver.Capabilities;
23+
const server = `http://localhost:4444/wd/hub`;
24+
2425
switch (process.env.BROWSER || "chrome") {
25-
case "safari": {
26-
capabilities = webdriver.Capabilities.safari();
26+
case "chrome": {
27+
driver = new webdriver.Builder()
28+
.usingServer(server)
29+
.withCapabilities({
30+
browserName: "chrome",
31+
})
32+
.build();
2733
break;
2834
}
2935
case "firefox": {
30-
require("geckodriver");
31-
capabilities = webdriver.Capabilities.firefox();
32-
break;
33-
}
34-
case "chrome": {
35-
require("chromedriver");
36-
capabilities = webdriver.Capabilities.chrome();
37-
capabilities.set("chromeOptions", {
38-
args: [
39-
"--headless",
40-
"--no-sandbox",
41-
"--disable-gpu",
42-
"--window-size=1980,1200",
43-
],
44-
});
36+
driver = new webdriver.Builder()
37+
.usingServer(server)
38+
.withCapabilities({
39+
browserName: "firefox",
40+
})
41+
.build();
4542
break;
4643
}
4744
}
48-
driver = await new webdriver.Builder().withCapabilities(capabilities).build();
4945
});
5046

5147
afterAll(async () => {
5248
await driver.quit();
5349
});
5450

5551
it("loader should load map and getCenter", async () => {
52+
jest.setTimeout(30000);
5653
await driver.get("file://" + path.resolve(__dirname, "index.html"));
5754

5855
await expect(

package-lock.json

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@babel/runtime-corejs3": "^7.9.2",
3434
"@types/googlemaps": "^3.39.3",
3535
"@types/jest": "^25.2.1",
36+
"@types/selenium-standalone": "^6.15.0",
3637
"@types/selenium-webdriver": "^4.0.9",
3738
"@typescript-eslint/eslint-plugin": ">=2.25.0",
3839
"@typescript-eslint/parser": ">=2.25.0",
@@ -48,6 +49,7 @@
4849
"rollup-plugin-commonjs": "^10.1.0",
4950
"rollup-plugin-terser": "^5.3.0",
5051
"rollup-plugin-typescript2": "^0.27.0",
52+
"selenium-standalone": "^6.17.0",
5153
"selenium-webdriver": "^4.0.0-alpha.7",
5254
"ts-jest": "^25.3.1",
5355
"typedoc": "^0.17.0-3",

0 commit comments

Comments
 (0)