Skip to content

Commit

Permalink
fix(jasmine): user templated_args should be passed to jasmine after 3…
Browse files Browse the repository at this point in the history
… internal templated_args
  • Loading branch information
gregmagolan committed Mar 27, 2020
1 parent 2d9bef9 commit 0efa856
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/jasmine/src/jasmine_node_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def jasmine_node_test(
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 = []
templated_args.append("$(location :%s_devmode_srcs.MF)" % name)

if coverage:
Expand All @@ -91,6 +90,11 @@ def jasmine_node_test(
else:
templated_args.append("--noconfig")

# jasmine_runner.js consumes the first 3 args provided above.
# The remaining target templated_args will be passed through to jasmine or
# specs to consume.
templated_args.extend(kwargs.pop("templated_args", []))

nodejs_test(
name = name,
data = all_data,
Expand Down
13 changes: 13 additions & 0 deletions packages/jasmine/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ jasmine_node_test(
"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",
],
)

Expand All @@ -107,8 +112,16 @@ jasmine_node_test(
"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",
],
)

Expand Down
8 changes: 7 additions & 1 deletion packages/jasmine/test/args_test.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 0efa856

Please sign in to comment.