Skip to content

Latest commit

 

History

History
104 lines (71 loc) · 2.46 KB

README.md

File metadata and controls

104 lines (71 loc) · 2.46 KB

End to end testing

Prerequisite

In this document:

🚀 Quick start

  1. Install your dependencies:

    npm run bootstrap
  2. Install e2e testing dependencies:

    npm run install:qa
  3. Configure .env file:

    - Create a `.env` file in the root folder
    - Copy the contents from `.env.example` to it
    - Fill the essential values
    

  4. Run tests:

    npm run test:qa
    npm run test:performance
  5. Create new test:

    cd e2e_tests && npm run create_test {category_name} {test_name}
  6. File Structure

    src
        ├── __tests__/
        │   ├── [category_name]/
        |       ├── [test_name].test.js
        ├── _config/
        ├── _utils/
        ├── objects/
        ├── bootstrap.js
    
  7. Playwright documents: We use playwright to run our tests so it's very useful to take a look at this documentation.


Usage:

Create a browser

You can setup a browser with mobile or desktop viewport before runing each test starts and tear down the browser after runing each test like this:

```JS
const { setUp, tearDown, desktop_viewport, mobile_viewport } = require('@root/bootstrap');

beforeEach(async () => {
    const out = await setUp(mobile_viewport); // for mobile viewport
    const out = await setUp(desktop_viewport); // for desktop viewport
});

afterEach(async () => {
    await tearDown(browser);
});

test('It shouls pass', () => {
    // your test logic
});

```

Creating a page

You can create a page and navigate to `Home_Page` like this:

```JS
const { browser, context } = await setUp(mobile_viewport);
await context.addInitScript(replaceWebsocket);
const page = new Common(await context.newPage());
await page.navigate(); // navigate to HOME_URL (process.env.HOME_URL)

```

Now, you can use all helper functions in `@root/objects/common.js` to perform actions to the created page. Also, read [this](https://playwright.dev/docs/api/class-page) documentation to see more provided methods.