0.0.1 • Published 5 years ago

puppetest v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
5 years ago

Puppetest

Puppetest merges mocha and chai tests with puppeteer, adding some waiting features for being used from tests.

Usage

On your tests:

const Puppetest = require('puppetest').Puppetest;
const muyPathsMap = require('../puppetest-paths');
const config = require('../puppetest-config');

describe('Basic tests', function () {
  let page, puppetest;

  beforeEach(async function () {
    puppetest = new Puppetest(config);
    page = await puppetest.getPage();

    await page.setViewport({
      width: 1200,
      height: 650
    })
    await page.goto('https://www.virustotal.com/gui/')
  });
  it('Checks some concrete scenario', async function () {

      await puppetest.waitForPropValue(puppetest.paths.HOME_VIEW.SPINNER, 
        'loading', false);

      let welcomeDiv = await puppetest.domSearcher(puppetest.paths.HOME_VIEW.WELCOME);
      let messageParagraph = await welcomeDiv.$('p#message');
      let msg = await puppetest.getProp(messageParagraph, 'textContent');

      expect(msg.value).to.be.equal('Hi All!');
    });
  });
});

On your runner:

This example uses polyserve.

const TestRunner = require('puppetest').TestRunner;
const server = require('polyserve');

console.log('-- Launching server --');
server.startServer().then(() => {
  let testRunner = new TestRunner({ timeout: 50000, slow: 5000 },
    ['test-e2e/logged-out']);
  process.exitCode = testRunner.run().on('end', () => {
    console.log('-- Stopping server --');
    process.exit();
  });
});

More doc:

For further information, please dive the code or ask @recluising

0.0.1

5 years ago