17415: Created mountainduck bookmark files generator
[arvados-workbench2.git] / cypress / plugins / index.js
index b11d5528ce391160faf4bd5e6b98d448c6cf43e9..67262bcbef5da9daeab036bd634742c87a7f9369 100644 (file)
 // This function is called when a project is opened or re-opened (e.g. due to
 // the project's config changing)
 
+const fs = require('fs');
+const path = require('path');
+
 /**
  * @type {Cypress.PluginConfig}
  */
 module.exports = (on, config) => {
   // `on` is used to hook into various events Cypress emits
   // `config` is the resolved Cypress config
+  on("before:browser:launch", (browser = {}, launchOptions) => {
+    const downloadDirectory = path.join(__dirname, "..", "downloads");
+    if (browser.family === "chromium") {
+     launchOptions.preferences.default["download"] = {
+      default_directory: downloadDirectory
+     };
+    }
+    return launchOptions;
+  });
+
+  on('task', {
+    clearDownload({ filename }) {
+      fs.unlinkSync(filename);
+      return null;
+    }
+  });
 }