Skip to content

Commit e8d65f2

Browse files
obecnyvmarchaud
andauthored
chore: adding selenium tests with browserstack (#2570)
Co-authored-by: Valentin Marchaud <[email protected]>
1 parent 8227258 commit e8d65f2

File tree

23 files changed

+899
-5
lines changed

23 files changed

+899
-5
lines changed

.github/workflows/peer-api.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
run: npm install semver
2323

2424
- name: Check API dependency semantics (stable)
25-
run: lerna exec --ignore propagation-validation-server "node ../../scripts/peer-api-check.js"
25+
working-directory: packages
26+
run: lerna exec --ignore propagation-validation-server --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests "node ../../scripts/peer-api-check.js"
2627

2728
- name: Check API dependency semantics (experimental)
2829
working-directory: experimental
29-
run: lerna exec --ignore propagation-validation-server "node ../../../scripts/peer-api-check.js"
30+
run: lerna exec --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests "node ../../../scripts/peer-api-check.js"

.github/workflows/unit-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
if: steps.cache.outputs.cache-hit != 'true'
3636
run: |
3737
npm install --ignore-scripts
38-
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
38+
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --ignore @opentelemetry/selenium-tests
3939
4040
- name: Build 🔧
4141
run: |
@@ -111,7 +111,7 @@ jobs:
111111
working-directory: experimental
112112
run: |
113113
npm install --ignore-scripts
114-
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
114+
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --ignore @opentelemetry/selenium-tests
115115
116116
- name: Build 🔧
117117
working-directory: experimental

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"packages": [
66
"benchmark/*",
77
"packages/*",
8-
"integration-tests/*"
8+
"integration-tests/*",
9+
"selenium-tests"
910
]
1011
}

selenium-tests/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tests_output
2+
tmp

selenium-tests/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Selenium Tests
2+
3+
Selenium tests are to help verify the working of opentelemetry in different browsers. For that the nightwatch is used.
4+
This can be run either locally or in github actions with usage of browserstack.
5+
Browser stack also gives possibility of running tests in browserstack on different browsers using our local environment.
6+
This helps to test and debug things locally using any browser we want.
7+
8+
## Running tests locally using local browser - this is also useful when adding new test
9+
10+
1. run server
11+
12+
```shell
13+
npm run server
14+
```
15+
16+
1. run local test for example for xhr
17+
18+
```shell
19+
npm run local:xhr
20+
```
21+
22+
Please wait a bit it should run selenium tests using our local version of chrome
23+
24+
## Running tests locally using browser stack account - for that you need to have a browser stack account
25+
26+
If you have it please create a file ".env" based on "example.env"
27+
28+
1. run server
29+
30+
```shell
31+
npm run server
32+
```
33+
34+
1. Run local test for example for xhr
35+
36+
```shell
37+
npm run local:bs:xhr
38+
```
39+
40+
## Architecture
41+
42+
1. Folder pages contains all the pages that can be entered after running `npn run server` at <http://localhost:8090/> .
43+
These are fully functioning pages and can be run without running tests.
44+
45+
2. To be able to test it automatically instead of manually we have to create a test. Tests are kept in folder "tests".
46+
For each page there is a corresponding folder with exactly the same name. There are additional 2 files
47+
48+
- helper.js - this file keeps some helpers functions that are included in page automatically and they are available in tests only in section "execute".
49+
This is because this section is being sent to the browser and executed automatically. This is the only way of "sending" and "reading" data back to test
50+
When data is being sent between browser and selenium it needs to be stringified that's why we have one more helper for that called "JSONSafeStringify"
51+
The last helper is the one that helps to verify test has finished successfully "OTELSeleniumDone".
52+
53+
- tracing.js - this file contains the skeleton for tracing and export function "loadOtel" this is a helper function that accepts instrumentations as param.
54+
This way it is easy to add different tests that has different lists of instrumentations.

selenium-tests/babel.config.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = function (api) {
2+
api.cache(true);
3+
const presets = [
4+
[
5+
'@babel/preset-env',
6+
{
7+
corejs: {
8+
version: '3',
9+
proposals: true,
10+
},
11+
useBuiltIns: 'entry',
12+
targets: {
13+
// 'edge': 16,
14+
// 'safari': 9,
15+
// 'firefox': 57,
16+
'ie': 11,
17+
// 'ios': 9,
18+
// 'chrome': 49,
19+
},
20+
},
21+
],
22+
];
23+
const plugins = [
24+
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
25+
['@babel/plugin-proposal-class-properties', { 'loose': true }],
26+
["@babel/plugin-proposal-private-methods", { "loose": true }],
27+
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
28+
];
29+
return {
30+
presets,
31+
plugins,
32+
};
33+
};

selenium-tests/example.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BROWSERSTACK_USER="YOUR USER"
2+
BROWSERSTACK_KEY="YOUR BROWSER STACK KEY"

0 commit comments

Comments
 (0)