Coder Social home page Coder Social logo

webship / webship-js Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 3.0 1.14 MB

Webship-js is an Automated Functional Acceptance Testing tool. Helps to ease and speed the work with the End-to-end testing features in web apps or projects. Utilizing Nightwatch.js and Cucumber-js. Having custom and advanced general step definitions.

Home Page: https://webship.co

JavaScript 80.63% Gherkin 19.37%
acceptance-testing automated automated-testing automation cucumber-js end-to-end-testing functional-testing nightwatch-cucumber nightwatchjs selenium

webship-js's Introduction

Webship JS

Github Actions Gitlab CI CircleCI Bitbucket Pipelines

Webship-js is an Automated Functional Acceptance Testing tool. Helps to ease and speed the work with the End-to-end testing features in web apps or projects. Utilizing Nightwatch.js and Cucumber-js. Having custom and advanced general step definitions.

Webship-js Documentations

All you need to know is at webship-js Docs.

Install webship-js using Yarn

yarn add webship-js

Install files required by the webship-js tool

bash <(wget -O - https://raw.githubusercontent.com/webship/wbash/v1/webship-js/v1/template.sh)

Automated Functional Acceptance Testing

yarn test

webship-js's People

Contributors

natshah avatar shaimaanatshah avatar tasneemnatshah avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

webship-js's Issues

Fix calling (config file, src folders) while using (default package, default package in project, project) commands

We have 3 different callings (config file, src folders):

1. Out of the project, package default commands, which call the main webship.conf.js, and 'test/step-definitions' folder both exist in the package root.
2. Inside the project, package default commands, which call the main webship.conf.js, and 'test/step-definitions' folder both exist in './node_modules/webship-js/'.
3. Command arguments, which call files and directories depending on the arguments' full path.

Remove a global js file containing filter and add option tags into command line

Option tags added to the command line:
(--config)
To get the project config file that has main paths for step definitions.
Example:
--config="path/to/file/nightwatch.conf.js"

(--src_folders)
To get the additional files in additional folders for step definitions.
Example:
--src_folders="path/to/folder/folder1 path/to/folder/folder2"

(--format)
To set step definitions list display format.
Example:
--format="stdout-dashes" // To display dashes between list lines

Change -d argument parser into tow arguments: -l , -i for calling step definitions list

Separate -d argument into two arguments:
-l : to show step definitions in the list without information
-i : to show step definitions in the list with extra information

Example:

node ./bin/steplist -i

Given I go to "([^"]*)?"
Navigate to a url.
Exmaple:
 - Given I go to "https://webship.co"

Then I should( not)* see "([^"]*)?"
Asserting a text in the page.
Exmaple:
- Then I should see "Welcome"
- Then I should not see "Access denied"

And --help will changed:

node ./bin/steplist -h

usage: steplist.js [-h] [-v] [-l] [-i] [-c CONFIG] [-s SRC_FOLDERS] [-f FORMAT]

Argparse example

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -l, --list            Display step definitions list without information.
  -i, --information     Display step definitions list with information.
  -c CONFIG, --config CONFIG
                        Add your nightwatch config file, Example: -c="config.js" OR
                        -c=config.js OR -c config.js
  -s SRC_FOLDERS, --src_folders SRC_FOLDERS
                        Add your step definitions folder/s path, Example: -s="path/to/folder1"
                        OR -s="path/to/folder1 path/to/folder2", You can add as much as you
                        want of folder paths
  -f FORMAT, --format FORMAT
                        Choose step definitions list format style, just add a number. (1)
                        stdout-space. (2) stdout-dashes. Example: -f=1 OR -f 2

Fix webship-js step-definitions

Some errors must be fixed:

  1. "function" words are missing in some function's head
  2. End-function brackets " ); " are missing in some functions
  3. Function comments do not explain the function's work and there is no example

Releas webship-js 1.0.2

  • Add the 1.0.2 to the version in the package.json
  • Remove --headless from the nightwatch.conf.js

Linting JavaScript and no extension node files using ESLint linter

First we need to add 2 files to the main root of the project:
1- .eslintrc.json file that contains rules of js code check
2- .eslintignore file that contains the path of files and folders out of check

Then in package.json add "eslint" libraries to install when yarn install

"eslint": "~8.0",d
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4"

And in package.json add "lint:js" script
"lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json ." to lint js files
"lint:js-dl": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json bin/webship-js-dl", to lint webship-js-dl file which has no extension
"lint:js-di": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json bin/webship-js-di" to lint webship-js-di file which has no extension

Finally, check it on the terminal screen:
yarn lint:js
And
yarn lint:js --fix to fix basic errors

Add better shorter command names, with nodejs argparse function

CLI arguments parser for node.js is different from the original (python) in some points:

1. JS has no keyword arguments support.
- Pass options instead: new ArgumentParser({ description: 'example', add_help: true }).
2. JS has no python's types int, float, ...
- Use string-typed names: .add_argument('-b', { type: 'int', help: 'help' }).
3. %r format specifier uses require('util').inspect().

https://github.com/nodeca/argparse

Example:
-h or --help will provide valuable help messages:
node ./bin/steplist --help

usage: steplist [-h] [-v] [-d DISPLAY_LIST_INFORMATION] [-c CONFIG] [-s SRC_FOLDERS] [-f FORMAT]

Argparse example

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -d DISPLAY_LIST_INFORMATION, --display-list-information DISPLAY_LIST_INFORMATION
                        Chose step definitions list to display with or without information. l: for normal
                        list, i: with information list. Example: -d="i" OR -d=i OR -d i
  -c CONFIG, --config CONFIG
                        Add your nightwatch config file, Example: -c="config.js" OR -c=config.js OR -c
                        config.js
  -s SRC_FOLDERS, --src_folders SRC_FOLDERS
                        Add your step definitions folder/s path, Example: -s="path/to/folder1" OR
                        -s="path/to/folder1 path/to/folder2", You can add as much as you want of folder
                        paths
  -f FORMAT, --format FORMAT
                        Choose step definitions list format style, just add a number. (1) stdout-space.
                        (2) stdout-dashes. Example: -f=1 OR -f 2

Example for using arguments:

node ./bin/steplist -d l

Given I go to "([^"]*)?"

Then I should( not)* see "([^"]*)?"

node ./bin/steplist -d i

Given I go to "([^"]*)?"
Navigate to a url.
Exmaple:
 - Given I go to "https://webship.co"

Then I should( not)* see "([^"]*)?"
Asserting a text in the page.
Exmaple:
- Then I should see "Welcome"
- Then I should not see "Access denied"

Delete "bin" directory, and moving its contents "steplist.js" file out

Some files were missing when installing "webship-js" as a package, which happened after adding the "bin" folder to collect
js commands files.

So this an experience to delete the "bin" directory, after changing multi commands into one keyword command and one file "steplist.js", and put it into package root.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.