1load("@aspect_rules_js//js:defs.bzl", "js_test") 2load("@aspect_rules_js//npm:defs.bzl", "npm_link_package") 3load("//:typescript.bzl", "flatbuffer_ts_library") 4 5package(default_visibility = ["//visibility:private"]) 6 7# This is a copy of //ts:node_modules/flatbuffers. The rules_js-based tests 8# require this target to live in the same or a parent package. Since we don't 9# want to put rules_js targets in the root package, we create a copy here. 10npm_link_package( 11 name = "node_modules/flatbuffers", 12 src = "//ts:flatbuffers", 13 root_package = "tests/ts", 14) 15 16flatbuffer_ts_library( 17 name = "typescript_ts_fbs", 18 srcs = ["typescript_keywords.fbs"], 19 deps = [ 20 "//reflection/ts:reflection_ts_fbs", 21 "//tests/ts/test_dir:include_ts_fbs", 22 "//tests/ts/test_dir:typescript_transitive_ts_fbs", 23 ], 24) 25 26TEST_DATA = glob([ 27 "my-game/*.js", 28 "my-game/example/*.js", 29 "my-game/example2/*.js", 30]) 31 32TEST_UNION_VECTOR_DATA = glob([ 33 "union_vector/*.js", 34]) 35 36TEST_COMPLEX_ARRAYS_DATA = glob([ 37 "arrays_test_complex/**/*.js", 38]) 39 40# Here we're running the tests against the checked-in generated files. These 41# are kept up-to-date with a CI-based mechanism. The intent of running these 42# tests here via bazel is not to validate that they're up-to-date. Instead, we 43# just want to make it easy to run these tests while making other changes. For 44# example, this is useful when making changes to the rules_js setup to validate 45# that the basic infrastructure is still working. 46[js_test( 47 name = "%s_test" % test, 48 chdir = package_name(), 49 data = data + [ 50 "package.json", 51 "//tests:test_data_copied_to_bin", 52 "//tests/ts:node_modules/flatbuffers", 53 ], 54 entry_point = "%s.js" % test, 55) for test, data in ( 56 ("JavaScriptTest", TEST_DATA), 57 ("JavaScriptUnionVectorTest", TEST_UNION_VECTOR_DATA), 58 # TODO(philsc): Figure out how to run this test with flexbuffers available. 59 # At the moment the flexbuffer library is not exposed as a bazel target. 60 #("JavaScriptFlexBuffersTest", TBD_DATA) 61 ("JavaScriptComplexArraysTest", TEST_COMPLEX_ARRAYS_DATA), 62)] 63