Skip to content

Commit

Permalink
feat: enhanced logger and tests (#189)
Browse files Browse the repository at this point in the history
- enhanced Logger: allows for wdi5.getLogger("some-tag").log("test") results in [some-tag] test on the console
- core wdi5 tests: use mocha to test the WebdriverIO plugin itself

Co-authored-by: Sumesh Nair <[email protected]>
  • Loading branch information
vobu and nair-sumesh authored Mar 18, 2022
1 parent 1fd328c commit 959f159
Show file tree
Hide file tree
Showing 10 changed files with 574 additions and 63 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/wdi5-tests.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:
- name: build
run: npm run build

# run the actual tests
# run wdi5 core tests
- name: test wdi5 core
run: npm test

# run wdi5 tests within app(s)
- name: test js-app
run: HEADLESS=true npm run test:js-app
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "test/**/*.test.ts",
"require": "ts-node/register"
}
8 changes: 7 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Example: `5-5-17-46-47-screenshot--some-id.png`

## Logger

For convenient console output, use `wdi5.getLogger()`. It supports the `syslog`-like levels `log`, `info`, `warn` and `error`:
For convenient console output, use `wdi5.getLogger('tag')`. It supports the `syslog`-like levels `log`, `info`, `warn` and `error`:

```javascript
const wdi5 = require("wdi5")
Expand All @@ -318,6 +318,12 @@ wdi5.getLogger().log("any", "number", "of", "log", "parts")
The log level is set by the either in `wdio.conf.js` via `wdi5.logLevel` or
by `wdi5.getLogger().setLoglevel(level = {string} "error"| "verbose" | "silent")`

The 'tag' is an optional parameter and when passed will display logs on the console log with a prefix as follows:

```cmd
[TAG] any number of log parts
```

## Navigation

In the test, you can navigate the UI5 webapp via `goTo(options)` in one of two ways:
Expand Down
Loading

0 comments on commit 959f159

Please sign in to comment.