Skip to content

Commit

Permalink
chore: restore build_smoke_test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Dec 8, 2023
1 parent 3ce9faf commit 3b2d44d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion frontend/react/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary", "js_run_devserver")
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary", "js_run_devserver", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//react:tsconfig-to-swcconfig/package_json.bzl", tsconfig_to_swcconfig = "bin")
Expand Down Expand Up @@ -83,3 +83,12 @@ bin.vite_binary(
chdir = package_name(),
data = [":build"],
)

# Just verify that the bundle produced "something reasonable" but doesn't verify it functions in a browser.
# TODO: use something like Cypress for a true end-to-end test
js_test(
name = "build_smoke_test",
timeout = "short",
data = [":build"],
entry_point = "build_smoke_test.js",
)
6 changes: 3 additions & 3 deletions frontend/react/build_smoke_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const fs = require('fs');

// Make sure there's a file like build/static/js/main.12345678.js
const files = fs.readdirSync('react/build/static/js');
// Make sure there's a file like react/dist/assets/index.12345678.js
const files = fs.readdirSync('react/dist/assets');
console.log(files);
assert.ok(files.some((f) => /main\.[0-9a-f]{8}\.js/.test(f)));
assert.ok(files.some((f) => /index\.[0-9a-f]{8}\.js/.test(f)));

0 comments on commit 3b2d44d

Please sign in to comment.