Skip to content

Commit

Permalink
Re-implement smoke test with esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
pluma4345 committed Apr 30, 2024
1 parent 8fdef37 commit 597bbc6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:

web:
runs-on: ubuntu-latest
if: false

strategy:
matrix:
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"chai": "^4.4.1",
"esbuild": "^0.21.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-security": "^2.1.1",
"express": "^4.19.2",
"express-http-proxy": "^2.0.0",
"mocha": "^10.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"puppeteer": "^22.8.2",
"semver": "^7.6.0",
"source-map-support": "^0.5.21",
"typedoc": "^0.25.12",
Expand Down
36 changes: 25 additions & 11 deletions smoke-test.js → smoke-test.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
"use strict";
const puppeteer = require("puppeteer");
import esbuild from "esbuild";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

const express = require("express");
const proxy = require("express-http-proxy");
const { createReadStream } = require("fs");
const puppeteer = require("puppeteer");

const result = await esbuild.build({
entryPoints: ["build/esm/index.js"],
bundle: true,
format: "esm",
write: false,
});

const app = express();
app.get("/smoke", (_req, res) => {
res.type("html");
res.end('<!DOCTYPE html><script src="/smoke/web.js"></script>');
});
app.get("/smoke/web.js", (_req, res) => {
res.type("js");
createReadStream("build/web.js").pipe(res);
res.end(`<!DOCTYPE html>
<script type="importmap">
{
"imports": {
"arangojs": "/smoke/index.js"
}
}
</script>
`);
});
app.get("/smoke/web.js.map", (_req, res) => {
app.get("/smoke/index.js", (_req, res) => {
res.type("js");
createReadStream("build/web.js.map").pipe(res);
res.end(result.outputFiles[0].text);
});
app.use("/", proxy("arangodb:8529"));

Expand All @@ -29,7 +43,7 @@ app.listen(8529, () => {
waitUntil: "networkidle2",
});
const response = await page.evaluate(async () => {
// eslint-disable-next-line no-undef
const arangojs = await import("arangojs");
const Database = arangojs.Database;
const db = new Database();
try {
Expand Down

0 comments on commit 597bbc6

Please sign in to comment.