Skip to content

Commit

Permalink
async / await applied
Browse files Browse the repository at this point in the history
  • Loading branch information
aamirtestable committed Oct 25, 2021
1 parent e57027f commit e353718
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ const testableUtils = require('testable-utils');
const fireNow = testableUtils.isLocal || testableUtils.isSmokeTest;

describe('Load Url Requested in Event', function() {
it('should load url', function() {
it('should load url', async () => {
browser.testableLogInfo('Waiting on load-url event');
// no timeout (0), use Google url for local/smoke testing
const url = browser.testableWaitForEvent('load-url', 0, 'https://google.com');
browser.url(url);
browser.testableScreenshot('Requested Url');
await browser.url(url);
await browser.testableScreenshot('Requested Url');
});
});
```
Expand Down Expand Up @@ -435,7 +435,7 @@ Note that all the Webdriver.io commands can be used in a synchronous fashion.

### Screenshots

One command that has no `testable-utils` equivalent is `browser.testableScreenshot(name)`. This command takes a screenshot and puts it in the output directory to be collected as part of the test results. It also includes a prefix to make it easier to identify: `[region]-[chunk]-[user]-[iteration]-[name].png`. Tests are broken up into chunks, and within each chunk users and iterations are numbered starting at 0. So for example `us-east-1-123-0-0-MyHomePage.png` would be chunk id 123, first user, first iteration, image name `MyHomePage`.
One command that has no `testable-utils` equivalent is `await browser.testableScreenshot(name)`. This command takes a screenshot and puts it in the output directory to be collected as part of the test results. It also includes a prefix to make it easier to identify: `[region]-[chunk]-[user]-[iteration]-[name].png`. Tests are broken up into chunks, and within each chunk users and iterations are numbered starting at 0. So for example `us-east-1-123-0-0-MyHomePage.png` would be chunk id 123, first user, first iteration, image name `MyHomePage`.

### Command Mappings

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ declare global {
testableBarrier: (name: string, value?: any) => any;
testableInfo: () => any;

testableScreenshot: (name: string) => any;
testableScreenshot: (name: string) => Promise<any>;
testableStopwatch: (code: Function, metricName?: string, resource?: string) => any;
testableWaitForEvent: (eventName: string, timeout?: number, defaultVal?: any) => any;

Expand Down
4 changes: 2 additions & 2 deletions lib/wdio-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ function registerInfoCommands(browser, info, isLocal) {
browser.addCommand('testableInfo', function () {
return info;
});
browser.addCommand('testableScreenshot', function(name) {
browser.addCommand('testableScreenshot', async function(name) {
const path = pathModule.join(process.env.OUTPUT_DIR || '.', name + '.png');
browser.saveScreenshot(path);
await browser.saveScreenshot(path);
return path;
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testable-utils",
"version": "0.5.11",
"version": "0.5.12",
"description": "Utilities for Testable scripts",
"author": "Avi Stramer",
"keywords": [
Expand Down

0 comments on commit e353718

Please sign in to comment.