summaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
authorClombrong <clombrong@egregore.fun>2025-04-23 17:27:50 +0200
committerClombrong <cromblong@egregore.fun>2025-04-23 17:27:50 +0200
commit34f072dda231f0de4cfdcd86bfe921fcefc134fb (patch)
tree8630a3f75e71ef417f709560bf703b1dbc092c65 /test/js
parent3c935560874956d1b2d92024d09544b749a707b2 (diff)
feat: add custom rule to install npm polyfills for node testing
Diffstat (limited to 'test/js')
-rw-r--r--test/js/dune9
-rw-r--r--test/js/package-lock.json21
-rw-r--r--test/js/package.json5
-rw-r--r--test/js/polyfill.js1
4 files changed, 35 insertions, 1 deletions
diff --git a/test/js/dune b/test/js/dune
index d919a1e..83a2e60 100644
--- a/test/js/dune
+++ b/test/js/dune
@@ -2,4 +2,11 @@
(name websockets_hello)
(libraries portal_ws lwt js_of_ocaml)
(modes js)
- (preprocess (pps js_of_ocaml-ppx)))
+ (preprocess (pps js_of_ocaml-ppx))
+ (js_of_ocaml
+ (javascript_files polyfill.js)))
+
+(rule
+ (alias npm)
+ (deps package.json package-lock.json)
+ (action (system "npm ci")))
diff --git a/test/js/package-lock.json b/test/js/package-lock.json
new file mode 100644
index 0000000..8b5d148
--- /dev/null
+++ b/test/js/package-lock.json
@@ -0,0 +1,21 @@
+{
+ "name": "js",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "dependencies": {
+ "xmlhttprequest": "^1.8.0"
+ }
+ },
+ "node_modules/xmlhttprequest": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
+ "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ }
+ }
+}
diff --git a/test/js/package.json b/test/js/package.json
new file mode 100644
index 0000000..3b36bf4
--- /dev/null
+++ b/test/js/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "xmlhttprequest": "^1.8.0"
+ }
+}
diff --git a/test/js/polyfill.js b/test/js/polyfill.js
new file mode 100644
index 0000000..e394ec8
--- /dev/null
+++ b/test/js/polyfill.js
@@ -0,0 +1 @@
+global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;