1.3.1 • Published 4 months ago

play-ts-cucumber v1.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

Playwright (TS binding) + Cucumber (BDD)

Cucumber is a popular behavior-driven development (BDD) tool that allows developers and stakeholders to collaborate on defining and testing application requirements in a human-readable format. TypeScript is a powerful superset of JavaScript that adds optional static typing, making it easier to catch errors before runtime. By combining these two tools, we can create more reliable and maintainable tests.

Features

  1. Awesome report with screenshots, videos & logs
  2. Execute tests on multiple environments
  3. Parallel execution
  4. Rerun only failed features
  5. Retry failed tests on CI
  6. Github Actions integrated with downloadable report
  7. Page object model

Sample report

image

Project structure

  • app -> Contains all the features & Step Definitions Typescript code
  • dist -> Contains all framework code output files
  • play-ts-cucumber/dist -> Contains all framework code source files
  • test-results -> Contains all the reports related file

Reports

  1. Mutilple Cucumber Report
  2. Default Cucumber report
  3. Logs
  4. Screenshots of failure
  5. Test videos of failure
  6. Trace of failure

Get Started

Setup:

  1. Clone or download the project
  2. Extract and open in the VS-Code
  3. npm i to install the dependencies
  4. npx playwright install to install the browsers
  5. npm run test to execute the tests
  6. To run a particular test change
  paths: [
            "src/test/features/featurename.feature"
         ] 
  1. Use tags to run a specific or collection of specs
npm run test --TAGS="@test or @add"

Folder structure - May not be up to Date until folder structure is finalized.

  1. .vscode -> Settings for feature and step definition mapping
  2. app -> Folder for application related code and files
  3. app\env -> Multiple environments are handled
  4. app\pom\objects -> Page Object Model classes to have Object Locators
  5. app\pom\scripts -> Page Object Model classes to have custom methods related to the page
  6. pom.ts -> Global Objects and Scripts
  7. app\test-data -> Folder to have test data and test upload files
  8. app\test\features\<folder>\ -> write your features here (format: featureName.feature. You can have folders based on need)
  9. app\test\steps\<folder>\ -> Step definitions can be under the Feature folder here (format: featureName.step.ts)
  10. dist -> Compiled application code files generated here. No need to update/change anything here
  11. node_modules -> Dependency libraries are installed here
  12. play-ts-cucumber -> Framework code files. Development or changes should be made here
  13. test-results -> Folder to have execution reports and logs
  14. test-results\default-report -> Cucumber default report
  15. test-results\reports -> Multiple Cucumber report
  16. test-results\reports\assets -> CSS and font files for Multiple Cucumber report
  17. package.json -> Contains all the dependencies
  18. tsconfig.json -> TypeScript configurations

Core Framework

  1. actions -> Keyboard, Mouse and other user Action's on elements
    1. custom -> Custom action like Alert handling and etc.
    2. dropdown -> Dropdown actions
    3. element -> Methods depends on Elements e.g. Wait till disappearance of some element
    4. keyboard -> Keyboard actions
    5. mouse -> Mouse actions
    6. checkbox -> Check box actions
    7. dropdown -> Dropdown actions
    8. radiobutton -> Option button actions
    9. fileupload -> File Upload actions
  2. assertion -> Collection of Assertion
    1. assertion -> Text and various Assertions
    2. email -> Read email and assert email content
  3. browser -> Manage browser invoke and teardown
    1. browsermanager -> Manage browser items
  4. config -> Configuration files
    1. cucumber.js -> Cucumber profile configuration for test runner
  5. helper -> Cross ENV and DotEnv configurations
    1. env.ts -> Environment binding for Env variables
    2. types -> Type definition for Env variables
  6. hooks -> Cucumber hooks
    1. `hooks' -> Cucumber hooks implementation
    2. `pageFixture' -> Fixture and Page setup
  7. report -> Report and logger configurations
    1. 'custom_logger` -> Custom method for log generation
    2. init.ts -> Report initialization
    3. logger.ts -> Winston logger
    4. report.ts -> Cucumber Report Configuration
  8. global.ts -> Global access variables and class members and scripts
  9. runner.ts -> Received command line arguments and execute steps as defined

Running Test through Terminal (Command Prompt)

Syntax: npm run ccs_run_test -- ENV={Env} --FEATURES={Feature} --BROWSER={Chrome|Firefox|Webkit} --CLIENT={client} PARALLEL_WORKER={PARALLEL_WORKER_Count} - ENV is mandatory (required) argument. Value can be any one of the following: dev, test, qa, stage, ct, uat, prod - If no FEATURES are specified then it will run all features - If no TAGS are specified then it will run all scenarios of applicable features irrespective of tag - If no BROWSER is specified then default would be Chrome. Value can be only Chrome or Firefox or Webkit - If HEADLESS parameter is not specified then default would be Headless as false - If CLIENT parameter is not specified then it will be ignored - If REPORT_PATH parameter is not specified then report will be generated at folder test-results/default-report. Otherwise Cucumber default report HTML and JSON files will b generated at the specified location - If PARALLEL_WORKER parameter is not specified then default would be 1. If specified then given number of parallel execution will occur

  • The following will not work as ENV variable is mandatory npm run ccs_run_test
  • To execute all of the features with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD
  • To execute all of the features with PROD environment variables with Chrome for a specific client npm run ccs_run_test -- --ENV=PROD --CLIENT=TransAmerica
  • To execute all of the features under loginPage folder with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --FEATURES=app/test/features/loginPage
  • To execute all of the features under loginPage and booksPage folder with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --FEATURES=app/test/features/loginPage,app/test/features/booksPage
  • To execute all of the features under loginPage folder which are tagged as @auth with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --FEATURES=app/test/features/loginPage --TAGS="@auth"
  • To execute all of the features which are tagged as @auth with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --TAGS="@auth"
  • To execute all of the features which are tagged as @auth or @add with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --TAGS="@auth or @add"
  • To execute all of the features which are not tagged as @auth with PROD environment variables with Chrome npm run ccs_run_test -- --ENV=PROD --FEATURES=app/test/features/loginPage --TAGS="not @auth"
  • To execute all of the features with PROD environment variables with Firefox npm run ccs_run_test -- --ENV=PROD --BROWSER=Firefox
  • To execute all of the features with PROD environment variables with Webkit npm run ccs_run_test -- --ENV=PROD --BROWSER=Webkit
  • To execute all of the features with PROD environment variables with browser as Headless npm run ccs_run_test -- --ENV=PROD --BROWSER=Webkit --HEADLESS=true
  • To execute all of the features with PROD environment variables with browser as Headless and to generate the Report at downloads folder npm run ccs_run_test -- --ENV=PROD --BROWSER=Webkit --HEADLESS=true --REPORT_PATH=C:/users/Test/Downloads
  • To execute all of the features with PROD environment variables with browser as Headless in Parallel mode npm run ccs_run_test -- --ENV=PROD --BROWSER=Webkit --HEADLESS=true --PARALLEL_WORKER=2

Tutorials

  1. To know more about Framework - play-ts-cucumber
  2. Learn Playwright - Playwright - TS
  3. BDD in detail - TS binding
1.3.1

4 months ago

1.3.0

4 months ago

1.2.11

4 months ago

1.2.10

4 months ago

1.2.9

4 months ago

1.2.8

4 months ago

1.2.7

4 months ago

1.2.6

4 months ago

1.2.5

4 months ago

1.2.4

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.2.0

4 months ago

1.1.17

4 months ago

1.1.16

4 months ago

1.1.15

4 months ago

1.1.14

4 months ago

1.1.13

4 months ago

1.1.12

4 months ago

1.1.11

4 months ago

1.1.10

5 months ago

1.1.9

5 months ago

1.1.8

5 months ago

1.1.7

5 months ago

1.1.6

5 months ago

1.1.5

5 months ago

1.1.4

5 months ago

1.1.2

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago