Skip to content

Commit

Permalink
chore: adding selenium tests with browserstack
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny committed Oct 28, 2021
1 parent 357ec92 commit 422253a
Show file tree
Hide file tree
Showing 22 changed files with 895 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: npm install semver

- name: Check API dependency semantics (stable)
working-directory: packages
run: lerna exec --ignore propagation-validation-server "node ../../scripts/peer-api-check.js"

- name: Check API dependency semantics (experimental)
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"packages": [
"benchmark/*",
"packages/*",
"integration-tests/*"
"integration-tests/*",
"selenium-tests"
]
}
2 changes: 2 additions & 0 deletions selenium-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests_output
tmp
54 changes: 54 additions & 0 deletions selenium-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Selenium Tests

Selenium tests are to help verify the working of opentelemetry in different browsers. For that the nightwatch is used.
This can be run either locally or in github actions with usage of browserstack.
Browser stack also gives possibility of running tests in browserstack on different browsers using our local environment.
This helps to test and debug things locally using any browser we want.

## Running tests locally using local browser - this is also useful when adding new test

1. run server

```shell
npm run server
```

1. run local test for example for xhr

```shell
npm run local:xhr
```

Please wait a bit it should run selenium tests using our local version of chrome

## Running tests locally using browser stack account - for that you need to have a browser stack account

If you have it please create a file ".env" based on "example.env"

1. run server

```shell
npm run server
```

1. Run local test for example for xhr

```shell
npm run local:bs:xhr
```

## Architecture

1. Folder pages contains all the pages that can be entered after running `npn run server` at <http://localhost:8090/> .
These are fully functioning pages and can be run without running tests.

2. To be able to test it automatically instead of manually we have to create a test. Tests are kept in folder "tests".
For each page there is a corresponding folder with exactly the same name. There are additional 2 files

- helper.js - this file keeps some helpers functions that are included in page automatically and they are available in tests only in section "execute".
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
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"
The last helper is the one that helps to verify test has finished successfully "OTELSeleniumDone".

- tracing.js - this file contains the skeleton for tracing and export function "loadOtel" this is a helper function that accepts instrumentations as param.
This way it is easy to add different tests that has different lists of instrumentations.
33 changes: 33 additions & 0 deletions selenium-tests/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = function (api) {
api.cache(true);
const presets = [
[
'@babel/preset-env',
{
corejs: {
version: '3',
proposals: true,
},
useBuiltIns: 'entry',
targets: {
// 'edge': 16,
// 'safari': 9,
// 'firefox': 57,
'ie': 11,
// 'ios': 9,
// 'chrome': 49,
},
},
],
];
const plugins = [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
['@babel/plugin-proposal-class-properties', { 'loose': true }],
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
];
return {
presets,
plugins,
};
};
2 changes: 2 additions & 0 deletions selenium-tests/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BROWSERSTACK_USER="YOUR USER"
BROWSERSTACK_KEY="YOUR BROWSER STACK KEY"
Loading

0 comments on commit 422253a

Please sign in to comment.