Mockeer icon indicating copy to clipboard operation
Mockeer copied to clipboard

Add new config parameter to control if fixtures should be replaced

Open wallynm opened this issue 5 years ago • 0 comments

At some cases, while testing the application you may wish to keep the fixture fixed even in record mode because you need to guarantee all tests keep working without erase the fixtures/records that already finished.

Now, if you're in RECORD mode, you need to comment those finished tests that you already recorded or apply a .skip flag into them to don't lost them.

In those cases, your request doesn't need to be updated, with this config you have a safe way to proceed building your tests and making sure everything still works even in RECORD mode without lose the recorded fixtures.

Another good case, some tests doesn't need to be updated - but others do need, with this config you can ensure what need to be overwritten.

The configuration would be like this:

const mockeer = require('mockeer');
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await mockeer(browser, {
    replaceIfExists: false
  });
  await page.goto('https://www.example.com');
  await page.close();
  await browser.close();
})();

By default replaceIfExists is true, so the package works as before changing just when this new config is present.

wallynm avatar Sep 13 '19 15:09 wallynm