Skip to content

Commit

Permalink
[browser][docs] Add docs for running tests in different browser (#47109)
Browse files Browse the repository at this point in the history
* Add documentation on running tests using different Browsers other than chrome.

- XHARNESS_COMMAND="test-browser --browser=safari"
- Add ability to run against different browsers from the make file target `run-browser-tests` by adding `XHARNESS_BROWSER= ` to command line.

At the moment supported values are:
- `chrome`
- `safari`
- `firefox`

* Add gecko firefox requirements to testing docs.
  • Loading branch information
kjpou1 authored Jan 19, 2021
1 parent 598070c commit a78f7d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions docs/workflow/testing/libraries/testing-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ PATH=/Users/<your_user>/.jsvu/:$PATH V8
### Using Browser Instance
It's possible to run tests in a browser instance:

#### Chrome
- An installation of [ChromeDriver - WebDriver for Chrome](https://chromedriver.chromium.org) is required. Make sure to read [Downloads/Version Selection](https://chromedriver.chromium.org/downloads/version-selection) to setup a working installation of ChromeDriver.
- Include the [ChromeDriver - WebDriver for Chrome](https://chromedriver.chromium.org) location in your PATH environment. Default is `/Users/<your_user>/.chromedriver`

```bash
PATH=/Users/<your_user>/.chromedriver:$PATH
```

#### Gecko / Firefox

- Requires gecko driver [Github repository of Mozilla](https://github.com/mozilla/geckodriver/releases)
- Include the [Github repository of Mozilla](https://github.com/mozilla/geckodriver/releases) location in your PATH environment. Default is `/Users/<your_user>/.geckodriver`

```bash
PATH=/Users/<your_user>/.geckodriver:$PATH
```

## Building Libs and Tests for WebAssembly

Now we're ready to build everything for WebAssembly (for more details, please read [this document](../../building/libraries/webassembly-instructions.md#building-everything)):
Expand Down Expand Up @@ -101,6 +111,26 @@ To run all tests, including "outer loop" tests (which are typically slower and i
MSBUILD_ARGS=/p:OuterLoop=true make -C src/mono/wasm/ run-browser-tests-System.AppContext
```
### Running tests using different Browsers
It's possible to set a Browser explicitly by adding `--browser=` command line argument to `XHARNESS_COMMAND`:
- CLI
```
XHARNESS_COMMAND="test-browser --browser=safari" ./dotnet.sh build /t:Test src/libraries/System.AppContext/tests /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release
```
- Makefile target `run-browser-tests-<test>`
```
XHARNESS_BROWSER=firefox make -C src/mono/wasm/ run-browser-tests-System.AppContext
```
At the moment supported values are:
- `chrome`
- `safari`
- `firefox`
By default, `chrome` browser is used.
## Kicking off outer loop tests from GitHub Interface
Expand Down
4 changes: 3 additions & 1 deletion src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ escape_quote = $(subst ",\",$(1))
DOTNET=$(TOP)/dotnet.sh
JSVU=$(HOME)/.jsvu
CHROMEDRIVER?=$(HOME)/.chromedriver
GECKODRIVER?=$(HOME)/.geckodriver

#
# These variables are set by wasm.proj
Expand All @@ -22,6 +23,7 @@ SYSTEM_NATIVE_LIBDIR?=$(TOP)/src/libraries/Native/Unix/System.Native
ENABLE_ES6?=false
_MSBUILD_WASM_BUILD_ARGS=/p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=$(CONFIG)
ENABLE_METADATA_UPDATE?=false
XHARNESS_BROWSER?=chrome

all: build-native icu-files source-files header-files

Expand Down Expand Up @@ -180,7 +182,7 @@ run-tests-%:
PATH="$(JSVU):$(PATH)" $(DOTNET) build $(TOP)/src/libraries/$*/tests/ /t:Test $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS)

run-browser-tests-%:
PATH="$(CHROMEDRIVER):$(PATH)" XHARNESS_COMMAND=test-browser $(DOTNET) build $(TOP)/src/libraries/$*/tests/ /t:Test $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS)
PATH="$(GECKODRIVER):$(CHROMEDRIVER):$(PATH)" XHARNESS_COMMAND="test-browser --browser=$(XHARNESS_BROWSER)" $(DOTNET) build $(TOP)/src/libraries/$*/tests/ /t:Test $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS)

run-debugger-tests:
if [ ! -z "$(TEST_FILTER)" ]; then \
Expand Down

0 comments on commit a78f7d2

Please sign in to comment.