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

Add test coverage for manual_build_file_contents... #780

Merged
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
2 changes: 2 additions & 0 deletions examples/bazel_managed_deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
jasmine_node_test(
name = "test",
srcs = glob(["*.spec.js"]),
data = ["@npm//:bin_files"],
node_modules = "@npm//:node_modules",
)

Expand All @@ -15,6 +16,7 @@ jasmine_node_test(
jasmine_node_test(
name = "fine_grained_test",
srcs = glob(["*.spec.js"]),
data = ["@npm//:bin_files"],
deps = [
"@npm//jasmine",
"@npm//typescript",
Expand Down
5 changes: 5 additions & 0 deletions examples/bazel_managed_deps/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
# @npm//jasmine
yarn_install(
name = "npm",
manual_build_file_contents = """
filegroup(
name = "bin_files",
srcs = glob(["node_modules/.bin/*"]),
)""",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
11 changes: 11 additions & 0 deletions examples/bazel_managed_deps/deps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ describe('dependencies', () => {
() => {
require('jasmine-core');
});

it('.bin files should be in runfiles via @npm//:bin_files data dep', () => {
const files = ['jasmine', 'tsc', 'tsserver'];
for (const f of files) {
try {
expect(require.resolve(`.bin/${f}`).endsWith(`/npm/node_modules/.bin/${f}`)).toBe(true);
} catch (_) {
fail(`.bin/${f} not resolved`);
}
}
});
});