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.
- Awesome report with screenshots, videos & logs
- Execute tests on multiple environments
- Parallel execution
- Rerun only failed features
- Retry failed tests on CI
- Github Actions integrated with downloadable report
- Page object model
- .github -> yml file to execute the tests in GitHub Actions
- src -> Contains all the features & Typescript code
- test-results -> Contains all the reports related file
- Mutilple Cucumber Report
- Default Cucumber report
- Logs
- Screenshots of failure
- Test videos of failure
- Trace of failure
- Clone or download the project
- Extract and open in the VS-Code
- Cmd to install dependencies
npm i ts-node -D
npm i
to install the dependenciesnpx playwright install
to install the browsersnpm run test
to execute the tests- To run a particular test, change:
paths: [
"src/test/features/featurename.feature"
]
- Use tags to run a specific or collection of specs:
npm run test --tags="@ask"
- Run scenarios on a specific browser, assigning chromium, firefox or webkit(safari) to the key browser:
npm config set browser=webkit
npm run test --tags="@admin"
if browser kept empty, the framework fetch the browser type from .env file. If the browser is empty or unassigned in .env file, browserManager.ts will assign the default browser.
- Rerun failed sceanarios after the test execution by
npm run test --tags="@regression"
npm run test:failed
src\pages
-> All the page (UI screen)src\test\features
-> write your features heresrc\test\steps
-> Your step definitions goes heresrc\hooks\hooks.ts
-> Browser setup and teardown logicsrc\hooks\pageFixture.ts
-> Simple way to share the page objects to stepssrc\helper\env
-> Multiple environments are handledsrc\helper\types
-> To get environment code suggestionssrc\helper\report
-> To generate the reportconfig/cucumber.js
-> One file to do all the magicpackage.json
-> Contains all the dependenciessrc\helper\auth
-> Storage state (Auth file)src\helper\util
-> Read test data from json & logger
Playwright-TS-Cucumber project
├── .github
│ └── workflows
│ └── ci.yml
├── src
│ ├── pages
│ │ └── examplePage.ts
│ ├── test
│ │ ├── features
│ │ │ └── example.feature
│ │ ├── steps
│ │ │ └── exampleSteps.ts
│ ├── hooks
│ │ ├── hooks.ts
│ │ └── pageFixture.ts
│ ├── helper
│ │ ├── env
│ │ │ └── environment.ts
│ │ ├── types
│ │ │ └── types.ts
│ │ ├── report
│ │ │ └── reportGenerator.ts
│ │ ├── auth
│ │ │ └── auth.ts
│ │ ├── util
│ │ │ ├── testData.ts
│ │ │ └── logger.ts
│ │ ├── wrapper
│ │ │ └── wrapper.ts
│ │ ├── browsers
│ │ │ └── browserManager.ts
│ │ └── util
│ │ └── test-data
│ │ └── exampleData.json
├── config
│ └── cucumber.js
├── test-results
│ └── exampleReport.html
├── package.json
└── README.md