webship-js 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -14
- package/bin/webship-js-di +87 -0
- package/bin/webship-js-dl +70 -0
- package/bitbucket-pipelines.yml +37 -0
- package/package.json +3 -5
- package/tests/step-definitions/webship.js +6 -0
- package/.bitbucket-pipelines.yml +0 -36
package/README.md
CHANGED
|
@@ -7,26 +7,14 @@
|
|
|
7
7
|
Webship JS has a ready step definitions for automated functional testing.
|
|
8
8
|
|
|
9
9
|
### Using:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* [Cucumber-js](https://github.com/cucumber/cucumber-js)
|
|
11
|
+
* [Nightwatch.js](https://github.com/nightwatchjs/nightwatch)
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
### Webship-js Documentations
|
|
15
15
|
All you need to know about [webship-js Docs](https://webship.gitbook.io/webship-js-docs/).
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
## How to install using NPM
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
npm i webship-js
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## How to install using Yarn
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
yarn i webship-js
|
|
28
|
-
```
|
|
29
|
-
|
|
30
18
|
## How to configure your project to test using webship-js steps
|
|
31
19
|
|
|
32
20
|
### Install node js and yarn
|
|
@@ -70,5 +58,32 @@ google-chrome --version
|
|
|
70
58
|
|
|
71
59
|
### Run selenium standalone server
|
|
72
60
|
|
|
61
|
+
```
|
|
62
|
+
cd ~
|
|
63
|
+
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar
|
|
64
|
+
java -jar selenium-server-standalone-3.141.59.jar -port 4444
|
|
65
|
+
```
|
|
73
66
|
|
|
67
|
+
## How to install using Yarn
|
|
74
68
|
|
|
69
|
+
```
|
|
70
|
+
yarn add webship-js
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## How to install using NPM
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
npm install webship-js
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Automated Functional Acceptance Testing
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
yarn test
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Or
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm test
|
|
89
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
conf = require("./../nightwatch.conf.js");
|
|
5
|
+
const FoldersPath = conf.src_folders;
|
|
6
|
+
|
|
7
|
+
// console.log(process.argv);
|
|
8
|
+
|
|
9
|
+
for(var i=2; i<process.argv.length; i++)
|
|
10
|
+
FoldersPath.push(process.argv[i]);
|
|
11
|
+
|
|
12
|
+
FoldersPath.forEach(Folder_Path => {
|
|
13
|
+
|
|
14
|
+
fs.readdir(Folder_Path, function (err, files) {
|
|
15
|
+
|
|
16
|
+
if (err) {
|
|
17
|
+
return console.log('Unable to scan directory: ' + err);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
files.forEach(file => {
|
|
21
|
+
fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
|
|
22
|
+
if(err){
|
|
23
|
+
throw new Error(err);
|
|
24
|
+
}
|
|
25
|
+
const SplitByLine_Arr = data.split("\n");
|
|
26
|
+
const Trim_Arr = SplitByLine_Arr.map(element => {
|
|
27
|
+
return element.trim();
|
|
28
|
+
});
|
|
29
|
+
const StartWith_Arr = Trim_Arr.filter(StartWith);
|
|
30
|
+
const Steps_Arr = CleanStepsList(StartWith_Arr);
|
|
31
|
+
|
|
32
|
+
Steps_Arr.forEach(element => {
|
|
33
|
+
console.log(element);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Start with Function.
|
|
42
|
+
*
|
|
43
|
+
* Return list of array items start with (Given, Then, When,*).
|
|
44
|
+
*
|
|
45
|
+
* @param ArrLine
|
|
46
|
+
* @returns array
|
|
47
|
+
*/
|
|
48
|
+
function StartWith(ArrLine) {
|
|
49
|
+
return (ArrLine.startsWith('Given')
|
|
50
|
+
|| ArrLine.startsWith('Then')
|
|
51
|
+
|| ArrLine.startsWith('When')
|
|
52
|
+
|| ArrLine.startsWith('*'));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Clean Steps List
|
|
57
|
+
*
|
|
58
|
+
* Return list of array items cleand from unreadable chars
|
|
59
|
+
*
|
|
60
|
+
* @param ListArr
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function CleanStepsList(ListArr) {
|
|
64
|
+
var StepComment = '';
|
|
65
|
+
var NewArr = Array();
|
|
66
|
+
|
|
67
|
+
ListArr.forEach((element, index) => {
|
|
68
|
+
|
|
69
|
+
if(element.startsWith("* ")){
|
|
70
|
+
StepComment = StepComment + element.substring(2) + '\r\n';
|
|
71
|
+
}
|
|
72
|
+
else if(element.startsWith("/**") || element.startsWith("*/")){
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
{
|
|
77
|
+
const Filter1 = element.split("$/");
|
|
78
|
+
const Filter2 = Filter1[0].replace("(/^", ' ');
|
|
79
|
+
|
|
80
|
+
NewArr.push(Filter2 + '\r\n' + StepComment);
|
|
81
|
+
StepComment = '';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
});
|
|
85
|
+
return NewArr;
|
|
86
|
+
}
|
|
87
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
conf = require("./../nightwatch.conf.js");
|
|
6
|
+
var FoldersPath = conf.src_folders;
|
|
7
|
+
|
|
8
|
+
for(var i=2; i<process.argv.length; i++)
|
|
9
|
+
FoldersPath.push(process.argv[i]);
|
|
10
|
+
|
|
11
|
+
FoldersPath.forEach(Folder_Path => {
|
|
12
|
+
|
|
13
|
+
fs.readdir(Folder_Path, function (err, files) {
|
|
14
|
+
|
|
15
|
+
if (err) {
|
|
16
|
+
return console.log('Unable to scan directory: ' + err);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
files.forEach(file => {
|
|
20
|
+
fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
|
|
21
|
+
if(err){
|
|
22
|
+
throw new Error(err);
|
|
23
|
+
}
|
|
24
|
+
const SplitByLine_Arr = data.split("\n");
|
|
25
|
+
const Trim_Arr = SplitByLine_Arr.map(element => {
|
|
26
|
+
return element.trim();
|
|
27
|
+
});
|
|
28
|
+
const StartWith_Arr = Trim_Arr.filter(StartWith);
|
|
29
|
+
const Steps_Arr = CleanStepsList(StartWith_Arr);
|
|
30
|
+
|
|
31
|
+
Steps_Arr.forEach(element => {
|
|
32
|
+
console.log(element);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Start with Function.
|
|
41
|
+
*
|
|
42
|
+
* Return list of array items start with (Given, Then, When).
|
|
43
|
+
*
|
|
44
|
+
* @param ArrLine
|
|
45
|
+
* @returns array
|
|
46
|
+
*/
|
|
47
|
+
function StartWith(ArrLine) {
|
|
48
|
+
return (ArrLine.startsWith('Given')
|
|
49
|
+
|| ArrLine.startsWith('Then')
|
|
50
|
+
|| ArrLine.startsWith('When'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Clean Steps List
|
|
55
|
+
*
|
|
56
|
+
* Return list of array items cleand from unreadable chars
|
|
57
|
+
*
|
|
58
|
+
* @param ListArr
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
function CleanStepsList(ListArr) {
|
|
62
|
+
ListArr.forEach((element, index) => {
|
|
63
|
+
const Filter1 = element.split("$/");
|
|
64
|
+
const Filter2 = Filter1[0].replace("(/^", ' ');
|
|
65
|
+
|
|
66
|
+
ListArr[index] = Filter2;
|
|
67
|
+
});
|
|
68
|
+
return Arr;
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Template NodeJS build
|
|
2
|
+
|
|
3
|
+
# This template allows you to validate your NodeJS code.
|
|
4
|
+
# The workflow allows running tests and code linting on the default branch.
|
|
5
|
+
|
|
6
|
+
image: node:16
|
|
7
|
+
|
|
8
|
+
pipelines:
|
|
9
|
+
default:
|
|
10
|
+
- parallel:
|
|
11
|
+
- step:
|
|
12
|
+
name: selenium linting
|
|
13
|
+
script:
|
|
14
|
+
- docker version
|
|
15
|
+
- docker pull selenium/hub:latest
|
|
16
|
+
- docker pull selenium/standalone-chrome
|
|
17
|
+
- docker run -d -p 4444:4444 --name selenium-hub selenium/hub
|
|
18
|
+
- docker run --link selenium-hub:hub selenium/node-chrome
|
|
19
|
+
- chmod +x $DRIVERPATH
|
|
20
|
+
- mvn compiler:compile test allure:report
|
|
21
|
+
services:
|
|
22
|
+
- docker
|
|
23
|
+
caches:
|
|
24
|
+
- node
|
|
25
|
+
- step:
|
|
26
|
+
name: Build and Test
|
|
27
|
+
max-time: 3
|
|
28
|
+
script:
|
|
29
|
+
- sleep 1m
|
|
30
|
+
- yarn install
|
|
31
|
+
- yarn run test
|
|
32
|
+
caches:
|
|
33
|
+
- node
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
options:
|
|
37
|
+
docker: true
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"test": "test"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
|
|
11
10
|
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html"
|
|
12
|
-
|
|
13
11
|
},
|
|
14
12
|
"repository": {
|
|
15
13
|
"type": "git",
|
|
@@ -23,11 +21,11 @@
|
|
|
23
21
|
"homepage": "https://github.com/webship/webship-js",
|
|
24
22
|
"dependencies": {
|
|
25
23
|
"@cucumber/cucumber": "*",
|
|
26
|
-
"chromedriver": "*",
|
|
27
24
|
"@cucumber/pretty-formatter": "^1.0.0-alpha.2",
|
|
25
|
+
"chromedriver": "*",
|
|
28
26
|
"eslint": "^7.32.0",
|
|
29
|
-
"mocha": "^9.1.3",
|
|
30
27
|
"geckodriver": "*",
|
|
28
|
+
"mocha": "^9.1.3",
|
|
31
29
|
"nightwatch": "^2.1.7"
|
|
32
30
|
}
|
|
33
31
|
}
|
|
@@ -2,6 +2,10 @@ const {Given} = require('@cucumber/cucumber');
|
|
|
2
2
|
const {When, Before} = require('@cucumber/cucumber');
|
|
3
3
|
const {Then} = require('@cucumber/cucumber');
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* some description
|
|
7
|
+
* for first given function
|
|
8
|
+
*/
|
|
5
9
|
Given(/^I go to "([^"]*)?"$/, function(url) {
|
|
6
10
|
return browser.url(url);
|
|
7
11
|
});
|
|
@@ -13,3 +17,5 @@ Then(/^I should( not)* see "([^"]*)?"$/, function(negativeCase, expectedText) {
|
|
|
13
17
|
|
|
14
18
|
return browser.assert.textContains('body', expectedText);
|
|
15
19
|
});
|
|
20
|
+
|
|
21
|
+
|
package/.bitbucket-pipelines.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
image: node:16
|
|
2
|
-
pipelines:
|
|
3
|
-
branches:
|
|
4
|
-
1.0.x:
|
|
5
|
-
- step:
|
|
6
|
-
name: "Webship-js CI"
|
|
7
|
-
caches:
|
|
8
|
-
- node
|
|
9
|
-
script:
|
|
10
|
-
- npm install
|
|
11
|
-
- npm run http://selenium:4444/wd/hub --host=selenium__standalone-chrome
|
|
12
|
-
- yarn install
|
|
13
|
-
- yarn test
|
|
14
|
-
- parallel:
|
|
15
|
-
- step:
|
|
16
|
-
name: "Selenium Tests"
|
|
17
|
-
caches:
|
|
18
|
-
- node
|
|
19
|
-
services:
|
|
20
|
-
- hub
|
|
21
|
-
- chrome
|
|
22
|
-
script:
|
|
23
|
-
- ./vendor/bin/phpunit --testsuite=selenium --cache-result-file=app/cache/.phpunit.result.cache
|
|
24
|
-
definitions:
|
|
25
|
-
caches:
|
|
26
|
-
- node
|
|
27
|
-
services:
|
|
28
|
-
hub:
|
|
29
|
-
image: selenium/hub
|
|
30
|
-
environment:
|
|
31
|
-
BROWSER: chrome
|
|
32
|
-
chrome:
|
|
33
|
-
image: selenium/node-chrome:3.141.5
|
|
34
|
-
environment:
|
|
35
|
-
HUB_PORT_4444_TCP_ADDR: 127.0.0.1
|
|
36
|
-
HUB_PORT_4444_TCP_PORT: "4444"
|