diff --git a/packages/jasmine/jasmine_node_test.bzl b/packages/jasmine/jasmine_node_test.bzl index b39503e1a0..8700683537 100644 --- a/packages/jasmine/jasmine_node_test.bzl +++ b/packages/jasmine/jasmine_node_test.bzl @@ -21,6 +21,7 @@ than launching a test in Karma, for example. load("@rules_nodejs//nodejs:providers.bzl", "JSModuleInfo") load("//packages/jasmine/private:index.bzl", "bazel_jasmine_runner_test") load("@build_bazel_rules_nodejs//internal/node:node.bzl", nodejs_test = "nodejs_test_macro") +load("@build_bazel_rules_nodejs//internal/common:is_js_file.bzl", "is_javascript_file") def _js_sources_impl(ctx): depsets = [] @@ -36,7 +37,7 @@ def _js_sources_impl(ctx): ctx.actions.write(ctx.outputs.manifest, "".join([ f.short_path + "\n" for f in sources.to_list() - if f.path.endswith(".js") or f.path.endswith(".mjs") + if is_javascript_file(f) ])) return [DefaultInfo(files = sources)] diff --git a/packages/jasmine/test/BUILD.bazel b/packages/jasmine/test/BUILD.bazel index ae5d92dfc9..b37a2f94e8 100644 --- a/packages/jasmine/test/BUILD.bazel +++ b/packages/jasmine/test/BUILD.bazel @@ -3,33 +3,54 @@ load("//internal/common:copy_to_bin.bzl", "copy_to_bin") load("//packages/jasmine:index.bzl", "jasmine_node_test") load("//packages/typescript:index.bzl", "ts_project") -jasmine_node_test( - name = "underscore_spec_test", - srcs = ["foo_spec.js"], -) +_JS_EXTENSIONS = [ + "js", + "cjs", + "mjs", +] + +[ + jasmine_node_test( + name = "underscore_spec_%s_test" % ext, + srcs = ["foo_spec.%s" % ext], + ) + for ext in _JS_EXTENSIONS +] # Verify that a bootstrap script does not break the test -jasmine_node_test( - name = "underscore_spec_bootstrap_test", - srcs = ["foo_spec.js"], - data = ["bootstrap.js"], - templated_args = ["--node_options=--require=$$(rlocation $(location :bootstrap.js))"], -) - -jasmine_node_test( - name = "underscore_test_test", - srcs = ["foo_test.js"], -) - -jasmine_node_test( - name = "dot_spec_test", - srcs = ["foo.spec.js"], -) - -jasmine_node_test( - name = "dot_test_test", - srcs = ["foo.test.js"], -) +[ + jasmine_node_test( + name = "underscore_spec_%s_bootstrap_test" % ext, + srcs = ["foo_spec.%s" % ext], + data = ["bootstrap.js"], + templated_args = ["--node_options=--require=$$(rlocation $(location :bootstrap.js))"], + ) + for ext in _JS_EXTENSIONS +] + +[ + jasmine_node_test( + name = "underscore_test_%s_test" % ext, + srcs = ["foo_test.%s" % ext], + ) + for ext in _JS_EXTENSIONS +] + +[ + jasmine_node_test( + name = "dot_spec_%s_test" % ext, + srcs = ["foo.spec.%s" % ext], + ) + for ext in _JS_EXTENSIONS +] + +[ + jasmine_node_test( + name = "dot_test_%s_test" % ext, + srcs = ["foo.test.%s" % ext], + ) + for ext in _JS_EXTENSIONS +] jasmine_node_test( name = "sharding_test", diff --git a/packages/jasmine/test/foo.spec.cjs b/packages/jasmine/test/foo.spec.cjs new file mode 100644 index 0000000000..b0f7bd50e8 --- /dev/null +++ b/packages/jasmine/test/foo.spec.cjs @@ -0,0 +1,5 @@ +describe('spec in file ending with .spec.cjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo.spec.mjs b/packages/jasmine/test/foo.spec.mjs new file mode 100644 index 0000000000..c5689425f5 --- /dev/null +++ b/packages/jasmine/test/foo.spec.mjs @@ -0,0 +1,5 @@ +describe('spec in file ending with .spec.mjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo.test.cjs b/packages/jasmine/test/foo.test.cjs new file mode 100644 index 0000000000..0675482cb8 --- /dev/null +++ b/packages/jasmine/test/foo.test.cjs @@ -0,0 +1,5 @@ +describe('spec in file ending with .test.cjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo.test.mjs b/packages/jasmine/test/foo.test.mjs new file mode 100644 index 0000000000..dc8d660685 --- /dev/null +++ b/packages/jasmine/test/foo.test.mjs @@ -0,0 +1,5 @@ +describe('spec in file ending with .test.mjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo_spec.cjs b/packages/jasmine/test/foo_spec.cjs new file mode 100644 index 0000000000..be97dfaa09 --- /dev/null +++ b/packages/jasmine/test/foo_spec.cjs @@ -0,0 +1,5 @@ +describe('spec in file ending with _spec.cjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo_spec.mjs b/packages/jasmine/test/foo_spec.mjs new file mode 100644 index 0000000000..5c776a26c8 --- /dev/null +++ b/packages/jasmine/test/foo_spec.mjs @@ -0,0 +1,5 @@ +describe('spec in file ending with _spec.mjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo_test.cjs b/packages/jasmine/test/foo_test.cjs new file mode 100644 index 0000000000..b97a416102 --- /dev/null +++ b/packages/jasmine/test/foo_test.cjs @@ -0,0 +1,5 @@ +describe('spec in file ending with _test.cjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +}); diff --git a/packages/jasmine/test/foo_test.mjs b/packages/jasmine/test/foo_test.mjs new file mode 100644 index 0000000000..5ab7e765fb --- /dev/null +++ b/packages/jasmine/test/foo_test.mjs @@ -0,0 +1,5 @@ +describe('spec in file ending with _test.mjs', () => { + it('should run', () => { + expect(true).toBe(true); + }); +});