A long time back, tsickle was ported to bazel. Part of its test suite are (somewhat odd) targets that run its tests against TypeScript 2.4-2.8, for example:
https://github.com/angular/tsickle/tree/master/test_ts24
These basically create a local node_modules directory and then run the test suite against that, like so:
jasmine_node_test(
name = "golden_test",
srcs = [
"check_ts_version.js",
"//test:golden_test_lib",
],
node_modules = ":node_modules",
data = ["//:test_files"],
)
This is all nice and fine, except for the bit where it totally doesn't work and doesn't actually run the tests against the right TypeScript version (argh!).
What happens is that bazel + Jasmine build rules create a layout like so:
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test/golden_tsickle_test.js
...
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24/node_modules/typescript/...
The nested typescript package does have the right version:
$ jq .version bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24/node_modules/typescript/package.json
"2.4.2"
But as you can see, golden_tsickle_test.js does not have it as a parent, and so when that loads 'typescript', it just gets the latest version that's in the top level node_modules folder.
So, in a nutshell, ever since we moved tsickle to bazel, none of these tests tested what they claimed they tested :-(
I don't quite know how to fix this though. I've created a partial PR for rules_nodejs in #236. That does create a symlink tree "node_modules" in the right location. However, nodejs helpfully still de-references all symlinks when loading files, so it still bypasses that, and I still end up with TS2.9 being used for all my tests.
A long time back, tsickle was ported to bazel. Part of its test suite are (somewhat odd) targets that run its tests against TypeScript 2.4-2.8, for example:
https://github.com/angular/tsickle/tree/master/test_ts24
These basically create a local node_modules directory and then run the test suite against that, like so:
jasmine_node_test(
name = "golden_test",
srcs = [
"check_ts_version.js",
"//test:golden_test_lib",
],
node_modules = ":node_modules",
data = ["//:test_files"],
)
This is all nice and fine, except for the bit where it totally doesn't work and doesn't actually run the tests against the right TypeScript version (argh!).
What happens is that bazel + Jasmine build rules create a layout like so:
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test/golden_tsickle_test.js
...
bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24/node_modules/typescript/...
The nested typescript package does have the right version:
$ jq .version bazel-bin/test_ts24/golden_test.runfiles/tsickle/test_ts24/node_modules/typescript/package.json
"2.4.2"
But as you can see, golden_tsickle_test.js does not have it as a parent, and so when that loads 'typescript', it just gets the latest version that's in the top level node_modules folder.
So, in a nutshell, ever since we moved tsickle to bazel, none of these tests tested what they claimed they tested :-(
I don't quite know how to fix this though. I've created a partial PR for rules_nodejs in #236. That does create a symlink tree "node_modules" in the right location. However, nodejs helpfully still de-references all symlinks when loading files, so it still bypasses that, and I still end up with TS2.9 being used for all my tests.