Create a reusable cypress_test() macro

I want to write a couple of tests for some plotting web pages. I keep
asking other folks to validate that I didn't break anything. It's time
to automate this.

This patch creates a new macro that will make it easier for everyone
to write such tests. We're also converting the one existing Cypress
test to use the new macro.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I8ec82dc8ebdcc22a394f3b66fbc5c39e937adc6e
diff --git a/tools/build_rules/js/BUILD b/tools/build_rules/js/BUILD
index 2381fcb..1bbe769 100644
--- a/tools/build_rules/js/BUILD
+++ b/tools/build_rules/js/BUILD
@@ -1,6 +1,10 @@
 load("@npm//:@angular/compiler-cli/package_json.bzl", angular_compiler_cli = "bin")
 load(":ts.bzl", "ts_project")
 
+exports_files([
+    "cypress.config.js",
+])
+
 # Define the @angular/compiler-cli ngc bin binary as a target
 angular_compiler_cli.ngc_binary(
     name = "ngc",
diff --git a/tools/build_rules/js/cypress.config.js b/tools/build_rules/js/cypress.config.js
new file mode 100644
index 0000000..4eb1a82
--- /dev/null
+++ b/tools/build_rules/js/cypress.config.js
@@ -0,0 +1,22 @@
+const {defineConfig} = require('cypress');
+
+module.exports = defineConfig({
+  e2e: {
+    specPattern: ['*.cy.js'],
+    supportFile: false,
+    setupNodeEvents(on, config) {
+      on('before:browser:launch', (browser = {}, launchOptions) => {
+        launchOptions.args.push('--disable-gpu-shader-disk-cache');
+      });
+
+      // Lets users print to the console:
+      //    cy.task('log', 'message here');
+      on('task', {
+        log(message) {
+          console.log(message);
+          return null;
+        },
+      });
+    },
+  },
+});