# simple testing for web developers

**URL:** <https://forum.shopware.com/t/simple-testing-for-web-developers/65485>\
**Category:** International (English Only)\
**Tags:** programming\
**Created:** [13. März 2020 um 10:21 UTC](https://forum.shopware.com/t/simple-testing-for-web-developers/65485 "2020-03-13T10:21:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wontfix](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@wontfix](https://forum.shopware.com/u/wontfix)\
**Post date:** [13. März 2020 um 10:21 UTC](https://forum.shopware.com/t/simple-testing-for-web-developers/65485/1 "2020-03-13T10:21:13Z")

</div>

used selenium and its veeery flaky…  
tried cypress and its a nightmare (especially in headless vm)…  
then just found puppeteer, and its awesome!

- need to learn only handful of new (puppeteer) stuff
- write your test logic in vanilla (nodejs) javascript
- write your data-retrieval in vanilla (browser) javascript

cant get more simple than that:

```
const Pupp = require('puppeteer');

(async()=>{
    let URL = 'https://shopware5.local';
    let webb = await Pupp.launch({ignoreHTTPSErrors:true});
    let page = await webb.newPage();
    await page.setViewport({width:1024, height:768});

    console.log("1 combo in cart...");
    await page.goto(URL+"/frontend/combo/addtocart?id=1");
    await page.goto(URL+"/checkout/cart");
    let cart = await getPageCart(page);
    test("SW10010 cart quantity", cart.SW10010, 1);
    test("SW10012 cart quantity", cart.SW10012, 2);
    test("COMBO cart price", cart.COMBO, -1);

    // more tests...

    await webb.close();
})();

function test (msg, a, b)
{
    if (a == b) {
        console.log('[OK]', msg);
    } else {
        console.log('[FAIL]', msg, a, 'does not match with', b);
    }
}

// returns {:} for articles
// and {:} for vouchers
function getPageCart (page)
{
    return page.evaluate(()=>{
        // browser javascript not included, to protect the innocent html designers...
    });
}

```

_(not a fan of the await spam, but puppeteer insists on async workflow)_
