simple testing for web developers

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)