text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = saveScreenshot;
  
  var _fs = _interopRequireDefault(require("fs"));
  
  var _utils = require("../../utils");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  async function saveScreenshot(filepath) {
    if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
      throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
    }
  
    const absoluteFilepath = (0, _utils.getAbsoluteFilepath)(filepath);
    (0, _utils.assertDirectoryExists)(absoluteFilepath);
    const screenBuffer = await this.takeScreenshot();
    const screenshot = Buffer.from(screenBuffer, 'base64');
  
    _fs.default.writeFileSync(absoluteFilepath, screenshot);
  
    return screenshot;
  }