I'm tring to run jasmine test using bazel on my current directory, but it is complaining about no specs found.
I think it has something to do with the "srcs" variable that I am providing.
I tried [":spec/test.spec.ts"]
and [":spec"]
but none is working.
Command that I use: bazel run //packages/core:unit_test
File directory:
root
-packages
--core
---spec
----test.spec.ts
jasmine_node_test(
name = "unit_test",
srcs = [":spec/test.spec.ts"],
deps = [
"@npm//jasmine"
],
)
test.spec.ts
describe("A suite is just a function", function() {
var a;
it("and so is a spec", function() {
a = true;
expect(a).toBe(true);
});
});
Package.json
"devDependencies": {
"@bazel/bazel": "^0.24.1",
"@bazel/buildifier": "^0.22.0",
"@bazel/ibazel": "^0.10.2",
"@bazel/typescript": "^0.28.0",
"@types/node": "^12.0.0",
"tslib": "^1.9.3",
"typescript": "^3.4.5"
},
"dependencies": {
"@bazel/jasmine": "^0.32.2",
"@types/jasmine": "^3.3.13",
"jasmine": "^3.4.0"
}
I expect the test to run successfully.
I tried your code in a sample application using Bazel and it seems like you need to transpile your code to JS because you are trying to run a .ts file in a JS test runner.
Note: In your case a simple rename to *.js
will suffice (I checked).
BUILD.bazel
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
ts_library(
name = "files_to_compile",
srcs = ["test.spec.ts"]
)
jasmine_node_test(
name = "sampletest",
srcs = [":files_to_compile"]
)
OR
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
jasmine_node_test(
name = "sampletest",
srcs = ["test.spec.js"]
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With