fix(jasmine): user templated_args should be passed to jasmine after 3 internal templated_args (#1743)

diff --git a/packages/jasmine/src/jasmine_node_test.bzl b/packages/jasmine/src/jasmine_node_test.bzl
index 6f3c867..bae78bb 100644
--- a/packages/jasmine/src/jasmine_node_test.bzl
+++ b/packages/jasmine/src/jasmine_node_test.bzl
@@ -74,22 +74,19 @@
     all_data += [":%s_devmode_srcs.MF" % name]
     all_data += [Label("@bazel_tools//tools/bash/runfiles")]
 
-    # If the target specified templated_args, pass it through.
-    templated_args = kwargs.pop("templated_args", [])
-    templated_args.append("$(location :%s_devmode_srcs.MF)" % name)
-
-    if coverage:
-        templated_args.append("--coverage")
-    else:
-        templated_args.append("--nocoverage")
+    # jasmine_runner.js consumes the first 3 args.
+    # The remaining target templated_args will be passed through to jasmine or
+    # specs to consume.
+    templated_args = [
+        "$(location :%s_devmode_srcs.MF)" % name,
+        "--coverage" if coverage else "--nocoverage",
+        "$(location %s)" % config_file if config_file else "--noconfig",
+    ] + kwargs.pop("templated_args", [])
 
     if config_file:
         # Calculate a label relative to the user's BUILD file
         pkg = Label("%s//%s:__pkg__" % (native.repository_name(), native.package_name()))
         all_data.append(pkg.relative(config_file))
-        templated_args.append("$(location %s)" % config_file)
-    else:
-        templated_args.append("--noconfig")
 
     nodejs_test(
         name = name,
diff --git a/packages/jasmine/test/BUILD.bazel b/packages/jasmine/test/BUILD.bazel
index 4de30cc..9df8b1e 100644
--- a/packages/jasmine/test/BUILD.bazel
+++ b/packages/jasmine/test/BUILD.bazel
@@ -97,7 +97,12 @@
         "dynamic_import.js",
     ],
     args = [
+        # the --node_options arg will be consumed by the node launcher
         "--node_options=--experimental-modules",
+        # the remaining args should be passed to the spec
+        "arg1",
+        "arg2",
+        "arg3",
     ],
 )
 
@@ -107,8 +112,16 @@
         "args_test.js",
         "dynamic_import.js",
     ],
+    args = [
+        # args should be passed after templated_args
+        "arg3",
+    ],
     templated_args = [
+        # the --node_options templated arg will be consumed by the node launcher
         "--node_options=--experimental-modules",
+        # the remaining args should be passed to the spec
+        "arg1",
+        "arg2",
     ],
 )
 
diff --git a/packages/jasmine/test/args_test.js b/packages/jasmine/test/args_test.js
index 39b84ec..6c236c8 100644
--- a/packages/jasmine/test/args_test.js
+++ b/packages/jasmine/test/args_test.js
@@ -1,5 +1,11 @@
 describe('args', () => {
-  it('should pass through templated_args', async () => {
+  it('should pass through other templated_args', async () => {
+    // args that are not consumed by the node launcher should be passed through
+    // to the spec
+    expect(process.argv.slice(2)).toEqual(['arg1', 'arg2', 'arg3']);
+  });
+
+  it('should apply --node_options in templated_args', async () => {
     // without --node_options=--experimental-modules this will fail
     const dynamicImport = await import('./dynamic_import.js');
     dynamicImport.default.hello();