Skip to content

Commit 4c9e6c3

Browse files
Merge pull request #52 from Shahnawaz-Sk/master
Add session naming options, type definitions
2 parents da26de2 + a941354 commit 4c9e6c3

25 files changed

+21620
-6495
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
tests/
3+
coverage/
4+
node_modules/
5+
__mocks__/

.github/workflows/healthcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
run: npm install
2424

2525
- name: Run test
26-
run: npm run test
26+
run: npm run test

.github/workflows/test.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
name: Test
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
branches: [master]
10+
11+
# allows a subsequently queued workflow run to interrupt previous runs
12+
concurrency:
13+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
14+
cancel-in-progress: true
15+
16+
jobs:
17+
linux:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
node-version: [16.x, 18.x]
22+
env:
23+
LT_USERNAME: ${{ secrets.LT_USERNAME }}
24+
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Install dependencies
35+
run: npm ci --ignore-scripts
36+
37+
- name: Build
38+
run: npm run build
39+
40+
- name: Test
41+
run: npm run test
42+
43+
macos:
44+
runs-on: macos-latest
45+
env:
46+
LT_USERNAME: ${{ secrets.LT_USERNAME }}
47+
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v2
51+
52+
- name: Use Node.js 18.x
53+
uses: actions/setup-node@v2
54+
with:
55+
node-version: 18.x
56+
57+
- name: Install dependencies
58+
run: npm ci --ignore-scripts
59+
60+
- name: Build
61+
run: npm run build
62+
63+
- name: Test
64+
run: npm run test

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ node_modules/
22
*.log
33
build/
44
coverage/
5-
.eslintcache
5+
.lambdatest/
6+
.eslintcache
7+
.env

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ node_modules
44
tests
55
*.log
66
.eslintcache
7-
/.github/workflows
7+
.eslintignore
8+
babel.config.js
9+
/.github/workflows
10+
.lambdatest/
11+
__mocks__
12+
.*

README.md

Lines changed: 137 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,106 @@ WebdriverIO LambdaTest Service
77
88
## Installation
99

10+
```bash
11+
npm i wdio-lambdatest-service --save-dev
12+
```
13+
14+
Instructions on how to install `WebdriverIO` can be found [here.](https://webdriver.io/docs/gettingstarted.html)
1015

11-
The easiest way is to keep `wdio-lambdatest-service` as a devDependency in your `package.json`.
1216

13-
```json
14-
{
15-
"devDependencies": {
16-
"wdio-lambdatest-service": "^1.0.1"
17-
}
18-
}
17+
## Configuration
18+
19+
WebdriverIO has LambdaTest support out of the box. You should simply set `user` and `key` in your `wdio.conf.js` file. To enable the feature for app automation, set `product: 'appAutomation'` in your `wdio.conf.js` file. This service plugin provides supports for [LambdaTest Tunnel](https://www.lambdatest.com/support/docs/troubleshooting-lambda-tunnel/). Set `tunnel: true` also to activate this feature.
20+
21+
```js
22+
// wdio.conf.js
23+
exports.config = {
24+
// ...
25+
user: process.env.LT_USERNAME,
26+
key: process.env.LT_ACCESS_KEY,
27+
logFile : './logDir/api.log',
28+
services: [
29+
['lambdatest', {
30+
tunnel: true
31+
}]
32+
],
33+
// ...
34+
};
1935
```
2036

21-
You can simple do it by:
37+
## Options
38+
39+
In order to authorize to the LambdaTest service your config needs to contain a [`user`](https://webdriver.io/docs/options.html#user) and [`key`](https://webdriver.io/docs/options.html#key) option.
40+
41+
### tunnel
42+
Set this to true to enable routing connections from LambdaTest cloud through your computer. You will also need to set `tunnel` to true in browser capabilities.
43+
44+
Type: `Boolean`<br>
45+
Default: `false`
46+
47+
### lambdatestOpts
48+
Specified optional will be passed down to LambdaTest Tunnel. See [this list](https://www.lambdatest.com/support/docs/lambda-tunnel-modifiers/) for details.
49+
50+
Type: `Object`<br>
51+
Default: `{}`
52+
53+
### preferScenarioName
54+
Cucumber only. Set the session name to the Scenario name if only a single Scenario ran.
55+
Useful when running in parallel with [wdio-cucumber-parallel-execution](https://github.com/SimitTomar/wdio-cucumber-parallel-execution).
56+
57+
Type: `Boolean`<br />
58+
Default: `false`
59+
60+
### sessionNameFormat
61+
Customize the session name format.
62+
63+
Type: `Function`<br />
64+
Default (Cucumber/Jasmine): `(config, capabilities, suiteTitle) => suiteTitle`<br />
65+
Default (Mocha): `(config, capabilities, suiteTitle, testTitle) => suiteTitle + ' - ' + testTitle`
66+
67+
### sessionNameOmitTestTitle
68+
Mocha only. Do not append the test title to the session name.
69+
70+
Type: `Boolean`<br />
71+
Default: `false`
72+
73+
### sessionNamePrependTopLevelSuiteTitle
74+
Mocha only. Prepend the top level suite title to the session name.
75+
76+
Type: `Boolean`<br />
77+
Default: `false`
78+
79+
### setSessionName
80+
Automatically set the session name.
81+
82+
Type: `Boolean`<br />
83+
Default: `true`
84+
85+
### setSessionStatus
86+
Automatically set the session status (passed/failed).
87+
88+
Type: `Boolean`<br />
89+
Default: `true`
90+
91+
92+
## Steps to compile and publish
93+
1. git clone this repository.
94+
2. run "npm install"
95+
3. run "npm run build"
96+
4. Steps to Publish: run "npm login"
97+
5. run "npm publish --access public"
98+
99+
----
100+
101+
For more information on WebdriverIO see the [homepage](https://webdriver.io).
102+
WebdriverIO LambdaTest Service
103+
========================
104+
105+
[![WDIO health check](https://github.com/LambdaTest/wdio-lambdatest-service/actions/workflows/healthcheck.yml/badge.svg?branch=master)](https://github.com/LambdaTest/wdio-lambdatest-service/actions/workflows/healthcheck.yml)
106+
107+
> A WebdriverIO service that manages tunnel and job metadata for LambdaTest users.
108+
109+
## Installation
22110

23111
```bash
24112
npm i wdio-lambdatest-service --save-dev
@@ -33,7 +121,7 @@ WebdriverIO has LambdaTest support out of the box. You should simply set `user`
33121

34122
```js
35123
// wdio.conf.js
36-
export.config = {
124+
exports.config = {
37125
// ...
38126
user: process.env.LT_USERNAME,
39127
key: process.env.LT_ACCESS_KEY,
@@ -63,10 +151,49 @@ Specified optional will be passed down to LambdaTest Tunnel. See [this list](htt
63151
Type: `Object`<br>
64152
Default: `{}`
65153

154+
### preferScenarioName
155+
Cucumber only. Set the session name to the Scenario name if only a single Scenario ran.
156+
Useful when running in parallel with [wdio-cucumber-parallel-execution](https://github.com/SimitTomar/wdio-cucumber-parallel-execution).
157+
158+
Type: `Boolean`<br />
159+
Default: `false`
160+
161+
### sessionNameFormat
162+
Customize the session name format.
163+
164+
Type: `Function`<br />
165+
Default (Cucumber/Jasmine): `(config, capabilities, suiteTitle) => suiteTitle`<br />
166+
Default (Mocha): `(config, capabilities, suiteTitle, testTitle) => suiteTitle + ' - ' + testTitle`
167+
168+
### sessionNameOmitTestTitle
169+
Mocha only. Do not append the test title to the session name.
170+
171+
Type: `Boolean`<br />
172+
Default: `false`
173+
174+
### sessionNamePrependTopLevelSuiteTitle
175+
Mocha only. Prepend the top level suite title to the session name.
176+
177+
Type: `Boolean`<br />
178+
Default: `false`
179+
180+
### setSessionName
181+
Automatically set the session name.
182+
183+
Type: `Boolean`<br />
184+
Default: `true`
185+
186+
### setSessionStatus
187+
Automatically set the session status (passed/failed).
188+
189+
Type: `Boolean`<br />
190+
Default: `true`
191+
192+
66193
## Steps to compile and publish
67194
1. git clone this repository.
68195
2. run "npm install"
69-
3. run "npm run compile"
196+
3. run "npm run build"
70197
4. Steps to Publish: run "npm login"
71198
5. run "npm publish --access public"
72199

__mocks__/@wdio/logger.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { vi } from 'vitest'
2+
3+
export const logMock = {
4+
error: vi.fn(),
5+
debug: vi.fn(),
6+
warn: vi.fn(),
7+
info: vi.fn(),
8+
trace: vi.fn()
9+
}
10+
11+
const mock = () => logMock
12+
13+
mock.setLevel = vi.fn()
14+
mock.setLogLevelsConfig = vi.fn()
15+
mock.waitForBuffer = vi.fn()
16+
17+
export default mock

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
presets: [
33
['@babel/preset-env', {
44
targets: {
5-
node: 8
5+
node: 10
66
}
77
}]
88
],

0 commit comments

Comments
 (0)