Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement e2e tests using playwright-js #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ You will also see any lint errors in the console.

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

### for running e2e tests

Start the project
- `yarn start`

Run the tests
- to run all the feature: `yarn test:e2e tests/acceptance/feature`
- to run specific scenario of a feature: `yarn test:e2e tests/acceptance/feature/<name-of-feature-file>:<line-number-of-the-scenario>
34 changes: 34 additions & 0 deletions cucumber.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Before, BeforeAll, AfterAll, After } = require("@cucumber/cucumber");
const { chromium } = require("playwright");
const { expect } = require("@playwright/test");

// playwright expect to global
global.expect = expect;

BeforeAll(async function () {
// Browsers are expensive in Playwright so only create 1
global.browser = await chromium.launch({
// Not headless so we can watch test runs
headless: false,
// Slow so we can see things happening
// slowMo: 50,
});

});

AfterAll(async function () {

await global.browser.close();
});

// Create a new browser context and page per scenario
Before(async function () {
global.context = await global.browser.newContext();
global.page = await global.context.newPage();
});

// Cleanup after each scenario
After(async function () {
await global.page.close();
await global.context.close();
});
Loading