Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.13 KB

README.md

File metadata and controls

81 lines (59 loc) · 2.13 KB

End to end testing

🚀 Quick start

  1. Install your dependencies:

    npm run bootstrap
  2. Configure .env file:

    Create a .env file in the root folder and copy the contents from .env.example to it and fill the essential values.


  1. Run tests:

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

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

    src
        ├── __tests__/
        │   ├── [category_name]/
        |       ├── [test_name].test.js
        ├── _config/
        ├── _utils/
        ├── objects/
        ├── bootstrap.js
    
  4. 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:

    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:

    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 documentation to see more provided methods.