Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions packages/jasmine/src/jasmine_node_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,19 @@ 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.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,
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