Skip to content

Commit 9a0705b

Browse files
committed
updated dependencies and required changes
1 parent 6fa0d12 commit 9a0705b

12 files changed

Lines changed: 248 additions & 234 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules/
22
*.DS_Store
33
*.log
44
.vscode/
5-
package-lock.json
5+
package-lock.json
6+
.idea

conf/local.conf.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
exports.config = {
1+
export const config = {
22
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
33
key: process.env.LT_ACCESS_KEY || '<YOUR LAMBDATEST KEY>',
44
server: 'hub.lambdatest.com',
55

6-
capabilities: [{
7-
browserName: 'chrome',
8-
platform: 'Windows 10',
9-
version: 'latest',
10-
name: "cucumebrjs-local-test",
11-
build: "cucumber-js-LambdaTest",
12-
tunnel: 'true',
13-
}]
14-
}
6+
capabilities: [
7+
{
8+
browserName: 'chrome',
9+
platform: 'Windows 10',
10+
version: 'latest',
11+
name: 'cucumberjs-local-test',
12+
build: 'cucumber-js-LambdaTest',
13+
tunnel: true,
14+
},
15+
],
16+
};

conf/parallel.conf.js

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
1-
exports.config = {
1+
export const config = {
22
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
33
key: process.env.LT_ACCESS_KEY || '<YOUR LAMBDATEST KEY>',
44
server: 'hub.lambdatest.com',
55

66
commonCapabilities: {
7-
name: "cucumber-js-LambdaTest-parallel-tests",
8-
build: "cucumber-js-LambdaTest-parallel",
7+
name: 'cucumber-js-LambdaTest-parallel-tests',
8+
build: 'cucumber-js-LambdaTest-parallel',
99
},
1010

11-
capabilities: [{
12-
browserName: 'chrome',
13-
platform: 'Windows 10',
14-
version: 'latest'
15-
},{
16-
browserName: 'firefox',
17-
platform: 'Windows 10',
18-
version: 'latest'
19-
},{
20-
browserName: 'safari',
21-
platform: 'macOS 10.14',
22-
version: 'latest'
23-
},{
24-
browserName: 'internet explorer',
25-
platform: 'Windows 10',
26-
version: 'latest'
27-
}]
28-
}
11+
capabilities: [
12+
{
13+
browserName: 'chrome',
14+
platform: 'Windows 10',
15+
version: 'latest',
16+
},
17+
{
18+
browserName: 'firefox',
19+
platform: 'Windows 10',
20+
version: 'latest',
21+
},
22+
{
23+
browserName: 'safari',
24+
platform: 'macOS 10.14',
25+
version: 'latest',
26+
},
27+
{
28+
browserName: 'internet explorer',
29+
platform: 'Windows 10',
30+
version: 'latest',
31+
},
32+
],
33+
};
2934

30-
// Code to support common capabilities
31-
exports.config.capabilities.forEach(function(caps){
32-
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
35+
// Apply common capabilities to each browser config
36+
config.capabilities.forEach((caps) => {
37+
for (const key in config.commonCapabilities) {
38+
caps[key] = caps[key] || config.commonCapabilities[key];
39+
}
3340
});
34-

conf/parallelJenkins.conf.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
let myStr = process.env.LT_BROWSERS;
2-
myStr = myStr.replace(/operatingSystem/g, 'platform');
3-
myStr = myStr.replace(/browserVersion/g, 'version');
4-
myStr = myStr.replace(/resolution/g, 'screen_resolution');
1+
import fs from 'fs';
2+
3+
// Process and transform environment variable
4+
let myStr = process.env.LT_BROWSERS || '[]';
5+
myStr = myStr
6+
.replace(/operatingSystem/g, 'platform')
7+
.replace(/browserVersion/g, 'version')
8+
.replace(/resolution/g, 'screen_resolution');
9+
510
console.log(myStr);
611

7-
const fs = require('fs');
8-
let jsonData = JSON.parse(myStr);
12+
let jsonData;
13+
try {
14+
jsonData = JSON.parse(myStr);
15+
} catch (err) {
16+
console.error('Error parsing LT_BROWSERS JSON:', err);
17+
jsonData = [];
18+
}
919

10-
exports.config = {
20+
export const config = {
1121
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
1222
key: process.env.LT_ACCESS_KEY || '<YOUR LAMBDATEST KEY>',
1323
server: 'hub.lambdatest.com',
1424

1525
commonCapabilities: {
16-
name: "parallel_cucumber-js-LambdaTest-parallel-tests",
17-
build: "cucumber-js-LambdaTest-parallel",
26+
name: 'parallel_cucumber-js-LambdaTest-parallel-tests',
27+
build: 'cucumber-js-LambdaTest-parallel',
1828
},
1929

2030
capabilities: jsonData,
21-
}
31+
};
2232

23-
// Code to support common capabilities
24-
exports.config.capabilities.forEach(function(caps){
25-
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
33+
// Apply common capabilities to each capability
34+
config.capabilities.forEach((caps) => {
35+
for (const key in config.commonCapabilities) {
36+
caps[key] = caps[key] || config.commonCapabilities[key];
37+
}
2638
});
27-

conf/single.conf.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
exports.config = {
2-
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
1+
export const config = {
2+
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
33
key: process.env.LT_ACCESS_KEY || '<YOUR LAMBDATEST KEY>',
44
server: 'hub.lambdatest.com',
55

6-
capabilities: [{
7-
browserName: 'chrome',
8-
platform: 'Windows 10',
9-
version: 'latest',
10-
name: "cucumber-js-single-test",
11-
build: "cucumber-js-LambdaTest-single"
12-
}]
13-
}
6+
capabilities: [
7+
{
8+
browserName: 'chrome',
9+
platform: 'Windows 10',
10+
version: 'latest',
11+
name: 'cucumber-js-single-test',
12+
build: 'cucumber-js-LambdaTest-single'
13+
}
14+
]
15+
};

conf/singleJenkins.conf.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
exports.config = {
1+
export const config = {
22
user: process.env.LT_USERNAME || '<YOUR LAMBDATEST USERNAME>',
33
key: process.env.LT_ACCESS_KEY || '<YOUR LAMBDATEST KEY>',
44
server: 'hub.lambdatest.com',
55

6-
capabilities: [{
7-
browserName: process.env.LT_BROWSER_NAME,
8-
platform: process.env.LT_PLATFORM,
9-
version: process.env.LT_BROWSER_VERSION,
10-
name: "cucumber-js-single-test",
11-
build: "cucumber-js-LambdaTest-single"
12-
}]
13-
}
6+
capabilities: [
7+
{
8+
browserName: process.env.LT_BROWSER_NAME || 'chrome',
9+
platform: process.env.LT_PLATFORM || 'Windows 10',
10+
version: process.env.LT_BROWSER_VERSION || 'latest',
11+
name: 'cucumber-js-single-test',
12+
build: 'cucumber-js-LambdaTest-single'
13+
}
14+
]
15+
};
Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
1-
"use strict";
1+
import { When, Then } from '@cucumber/cucumber';
2+
import assert from 'assert';
23

3-
var assert = require("cucumber-assert");
4+
When('I click on first item on local app', async function () {
5+
await this.driver.get('https://lambdatest.github.io/sample-todo-app/');
6+
const firstItem = await this.driver.findElement({ name: 'li1' });
7+
await firstItem.click();
8+
});
49

5-
module.exports = function() {
6-
this.When(/^I click on first item on local app$/, function(next) {
7-
this.driver.get("https://lambdatest.github.io/sample-todo-app/");
8-
this.driver
9-
.findElement({ name: "li1" })
10-
.click()
11-
.then(next);
12-
});
13-
14-
this.When(/^I click on second item on local app$/, function(next) {
15-
this.driver
16-
.findElement({ name: "li2" })
17-
.click()
18-
.then(next);
19-
});
10+
When('I click on second item on local app', async function () {
11+
const secondItem = await this.driver.findElement({ name: 'li2' });
12+
await secondItem.click();
13+
});
2014

21-
this.When(/^I add new item "([^"]*)" on local app$/, function(
22-
newItemName,
23-
next
24-
) {
25-
var self = this;
26-
this.driver
27-
.findElement({ id: "sampletodotext" })
28-
.sendKeys(newItemName + "\n")
29-
.then(next);
30-
this.driver
31-
.findElement({ id: "addbutton" })
32-
.click()
33-
.then(next);
34-
});
15+
When('I add new item {string} on local app', async function (newItemName) {
16+
const inputBox = await this.driver.findElement({ id: 'sampletodotext' });
17+
await inputBox.sendKeys(`${newItemName}\n`);
18+
const addButton = await this.driver.findElement({ id: 'addbutton' });
19+
await addButton.click();
20+
});
3521

36-
this.Then(/^I should see new item in list "([^"]*)" on local app$/, function(
37-
item,
38-
next
39-
) {
40-
var self = this;
41-
this.driver
42-
.findElement({ xpath: "//html/body/div/div/div/ul/li[6]/span" })
43-
.getText()
44-
.then(function(text) {
45-
console.log(text);
46-
assert.equal(text, item, next, "Expected title to be " + item);
47-
});
22+
Then('I should see new item in list {string} on local app', async function (item) {
23+
const newItem = await this.driver.findElement({
24+
xpath: '//html/body/div/div/div/ul/li[last()]/span'
4825
});
49-
};
26+
const text = (await newItem.getText()).trim();
27+
console.log('Local new item text:', text);
28+
assert.strictEqual(
29+
text,
30+
item.trim(),
31+
`Expected title to be "${item.trim()}", but got "${text}"`
32+
);
33+
});
Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
1-
"use strict";
1+
import { When, Then } from '@cucumber/cucumber';
2+
import assert from 'assert';
23

3-
var assert = require("cucumber-assert");
4-
module.exports = function() {
5-
this.When(/^I click on first item$/, function(next) {
6-
this.driver.get("https://lambdatest.github.io/sample-todo-app/");
7-
this.driver
8-
.findElement({ name: "li1" })
9-
.click()
10-
.then(next);
11-
});
4+
When('I click on first item', async function () {
5+
await this.driver.get('https://lambdatest.github.io/sample-todo-app/');
6+
const firstItem = await this.driver.findElement({ name: 'li1' });
7+
await firstItem.click();
8+
});
129

13-
this.When(/^I click on second item$/, function(next) {
14-
this.driver
15-
.findElement({ name: "li2" })
16-
.click()
17-
.then(next);
18-
});
10+
When('I click on second item', async function () {
11+
const secondItem = await this.driver.findElement({ name: 'li2' });
12+
await secondItem.click();
13+
});
1914

20-
this.When(/^I add new item "([^"]*)"$/, function(newItemName, next) {
21-
var self = this;
22-
this.driver
23-
.findElement({ id: "sampletodotext" })
24-
.sendKeys(newItemName + "\n")
25-
this.driver
26-
.findElement({ id: "addbutton" })
27-
.click()
28-
.then(next);
29-
});
15+
When('I add new item {string}', async function (newItemName) {
16+
const inputBox = await this.driver.findElement({ id: 'sampletodotext' });
17+
await inputBox.sendKeys(`${newItemName}\n`);
18+
const addButton = await this.driver.findElement({ id: 'addbutton' });
19+
await addButton.click();
20+
});
3021

31-
this.Then(/^I should see new item in list "([^"]*)"$/, function(item, next) {
32-
var self = this;
33-
this.driver
34-
.findElement({ xpath: "//html/body/div/div/div/ul/li[6]/span" })
35-
.getText()
36-
.then(function(text) {
37-
console.log(text);
38-
assert.equal(text, item, next, "Expected title to be " + item);
39-
});
22+
Then('I should see new item in list {string}', async function (item) {
23+
const newItem = await this.driver.findElement({
24+
xpath: '//html/body/div/div/div/ul/li[last()]/span',
4025
});
41-
};
26+
const text = (await newItem.getText()).trim();
27+
console.log('New item text:', text);
28+
assert.strictEqual(
29+
text,
30+
item.trim(),
31+
`Expected title to be "${item}", but got "${text}"`
32+
);
33+
});

features/support/env.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
2+
import { setDefaultTimeout } from '@cucumber/cucumber';
23

3-
var configure = function() {
4-
this.setDefaultTimeout(60 * 1000);
5-
};
6-
7-
module.exports = configure;
4+
export function configure() {
5+
setDefaultTimeout(60 * 1000);
6+
}

0 commit comments

Comments
 (0)