-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
diff --git docs/rules.md docs/rules.md | ||
index 898c858..b24ca30 100644 | ||
--- docs/rules.md | ||
+++ docs/rules.md | ||
@@ -7,7 +7,7 @@ Public API re-exports | ||
## jasmine_test | ||
|
||
<pre> | ||
-jasmine_test(<a href="#jasmine_test-jasmine_repository">jasmine_repository</a>, <a href="#jasmine_test-kwargs">kwargs</a>) | ||
+jasmine_test(<a href="#jasmine_test-jasmine_repository">jasmine_repository</a>, <a href="#jasmine_test-module">module</a>, <a href="#jasmine_test-kwargs">kwargs</a>) | ||
</pre> | ||
|
||
|
||
@@ -18,6 +18,7 @@ jasmine_test(<a href="#jasmine_test-jasmine_repository">jasmine_repository</a>, | ||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="jasmine_test-jasmine_repository"></a>jasmine_repository | <p align="center"> - </p> | <code>"jasmine"</code> | | ||
+| <a id="jasmine_test-module"></a>module | <p align="center"> - </p> | <code>"cjs"</code> | | ||
| <a id="jasmine_test-kwargs"></a>kwargs | <p align="center"> - </p> | none | | ||
|
||
|
||
diff --git jasmine/defs.bzl jasmine/defs.bzl | ||
index c67bfde..156aa64 100644 | ||
--- jasmine/defs.bzl | ||
+++ jasmine/defs.bzl | ||
@@ -11,14 +11,14 @@ _jasmine_test = rule( | ||
toolchains = js_binary_lib.toolchains, | ||
) | ||
|
||
-def jasmine_test(jasmine_repository = "jasmine", **kwargs): | ||
+def jasmine_test(jasmine_repository = "jasmine", module = "cjs", **kwargs): | ||
_jasmine_test( | ||
enable_runfiles = select({ | ||
"@aspect_rules_js//js/private:enable_runfiles": True, | ||
"//conditions:default": False, | ||
}), | ||
entry_point = "@{}//:jasmine_entrypoint".format(jasmine_repository), | ||
- junit_reporter = "@{}//:junit_reporter".format(jasmine_repository), | ||
+ junit_reporter = _get_junit_reporter(module, jasmine_repository), | ||
data = kwargs.pop("data", []) + [ | ||
"@{}//:node_modules/jasmine".format(jasmine_repository), | ||
"@{}//:node_modules/jasmine-core".format(jasmine_repository), | ||
@@ -26,3 +26,11 @@ def jasmine_test(jasmine_repository = "jasmine", **kwargs): | ||
], | ||
**kwargs | ||
) | ||
+ | ||
+def _get_junit_reporter(module, jasmine_repository): | ||
+ if module == "cjs": | ||
+ return "@{}//:junit_reporter_cjs".format(jasmine_repository) | ||
+ elif module == "esm": | ||
+ return "@{}//:junit_reporter_mjs".format(jasmine_repository) | ||
+ else: | ||
+ fail("Unknown `module` value \"{}\", allowed values are: [\"cjs\", \"esm\"]".format(module)) | ||
diff --git jasmine/private/BUILD.bazel jasmine/private/BUILD.bazel | ||
index 55d7a1c..61339e4 100644 | ||
--- jasmine/private/BUILD.bazel | ||
+++ jasmine/private/BUILD.bazel | ||
@@ -2,7 +2,8 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
exports_files([ | ||
"runner.js", | ||
- "junit_reporter.js" | ||
+ "junit_reporter.cjs", | ||
+ "junit_reporter.mjs", | ||
]) | ||
|
||
# gazelle:exclude v*.*.*/* | ||
diff --git jasmine/private/junit_reporter.js jasmine/private/junit_reporter.cjs | ||
similarity index 100% | ||
rename from jasmine/private/junit_reporter.js | ||
rename to jasmine/private/junit_reporter.cjs | ||
diff --git jasmine/private/junit_reporter.mjs jasmine/private/junit_reporter.mjs | ||
new file mode 100644 | ||
index 0000000..a5991d0 | ||
--- /dev/null | ||
+++ jasmine/private/junit_reporter.mjs | ||
@@ -0,0 +1,13 @@ | ||
+import { JUnitXmlReporter } from "jasmine-reporters"; | ||
+import * as path from "path"; | ||
+ | ||
+const xmlOutputFile = process.env.XML_OUTPUT_FILE; | ||
+ | ||
+jasmine.getEnv().addReporter( | ||
+ new JUnitXmlReporter({ | ||
+ filePrefix: path.basename(xmlOutputFile), | ||
+ savePath: path.dirname(xmlOutputFile), | ||
+ consolidate: true, | ||
+ consolidateAll: true, | ||
+ }) | ||
+); | ||
diff --git jasmine/repositories.bzl jasmine/repositories.bzl | ||
index eafc981..314c7aa 100644 | ||
--- jasmine/repositories.bzl | ||
+++ jasmine/repositories.bzl | ||
@@ -50,9 +50,15 @@ If you need custom versions, please file an issue.""".format(jasmine_version, TO | ||
visibility = ["//visibility:public"], | ||
)""", | ||
"""copy_file( | ||
- name = "junit_reporter", | ||
- src = "@aspect_rules_jasmine//jasmine/private:junit_reporter.js", | ||
- out = "junit_reporter.js", | ||
+ name = "junit_reporter_cjs", | ||
+ src = "@aspect_rules_jasmine//jasmine/private:junit_reporter.cjs", | ||
+ out = "junit_reporter.cjs", | ||
+ visibility = ["//visibility:public"], | ||
+)""", | ||
+ """copy_file( | ||
+ name = "junit_reporter_mjs", | ||
+ src = "@aspect_rules_jasmine//jasmine/private:junit_reporter.mjs", | ||
+ out = "junit_reporter.mjs", | ||
visibility = ["//visibility:public"], | ||
)""", | ||
], |