-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add Store unit tests to Bazel
- Loading branch information
1 parent
9fd6b3d
commit 976c356
Showing
12 changed files
with
174 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
# Marker file indicating this folder is a Bazel package. | ||
# Needed so that tsconfig.json can be referenced from BUILD rules. | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# Needed so that tsconfig.json can be referenced from BUILD rules. | ||
exports_files(["tsconfig.json"]) | ||
|
||
# Temporary target to allow `bazel test ...` | ||
# TODO(alexeagle): remove as soon as there is any other test in the repo | ||
genrule( | ||
name = "true", | ||
outs = ["true.sh"], | ||
cmd = "echo true > $@", | ||
) | ||
|
||
sh_test( | ||
name = "tautology_test", | ||
srcs = [":true.sh"], | ||
filegroup( | ||
name = "ngrx_test_dependencies", | ||
# NB: rxjs is not in this list, because we build it from sources using the | ||
# label @rxjs//:rxjs | ||
srcs = glob(["/".join([ | ||
"node_modules", | ||
pkg, | ||
"**", | ||
ext, | ||
]) for pkg in [ | ||
"@angular", | ||
"jasmine", | ||
"jasmine-marbles", | ||
"typescript", | ||
"@types", | ||
] for ext in [ | ||
"*.js", | ||
"*.json", | ||
"*.d.ts", | ||
]]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load("//tools:defaults.bzl", "ts_test_library", "jasmine_node_test") | ||
|
||
ts_test_library( | ||
name = "test_lib", | ||
srcs = glob( | ||
[ | ||
"**/*.ts", | ||
], | ||
exclude = ["ngc/**/*.ts"], | ||
), | ||
deps = [ | ||
"//modules/store", | ||
"@rxjs", | ||
], | ||
) | ||
|
||
jasmine_node_test( | ||
name = "test", | ||
deps = [ | ||
":test_lib", | ||
"//modules/store", | ||
"@rxjs", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
"""Re-export of some bazel rules with repository-wide defaults.""" | ||
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library") | ||
load("@build_bazel_rules_nodejs//:defs.bzl", _jasmine_node_test = "jasmine_node_test") | ||
|
||
def ts_library(tsconfig = None, node_modules = None, **kwargs): | ||
if not tsconfig: | ||
tsconfig = "//:tsconfig.json" | ||
if not node_modules: | ||
node_modules = "@ngrx_compiletime_deps//:node_modules" | ||
_ts_library(tsconfig = tsconfig, node_modules = node_modules, **kwargs) | ||
|
||
def ts_test_library(node_modules = None, **kwargs): | ||
if not node_modules: | ||
node_modules = "//:ngrx_test_dependencies" | ||
ts_library(node_modules = node_modules, testonly = 1, **kwargs) | ||
|
||
def jasmine_node_test(node_modules = None, bootstrap = None, deps = [], **kwargs): | ||
if not node_modules: | ||
node_modules = "//:ngrx_test_dependencies" | ||
if not bootstrap: | ||
bootstrap = ["ngrx/tools/testing/bootstrap_node_tests.js"] | ||
_jasmine_node_test( | ||
bootstrap = bootstrap, | ||
node_modules = node_modules, | ||
deps = ["//tools/testing:node"] + deps, | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//tools:defaults.bzl", "ts_test_library") | ||
|
||
ts_test_library( | ||
name = "node", | ||
srcs = ["bootstrap_node_tests.ts"], | ||
deps = [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'core-js/es7/reflect'; | ||
import 'zone.js/dist/zone-node.js'; | ||
import 'zone.js/dist/long-stack-trace-zone.js'; | ||
import 'zone.js/dist/proxy.js'; | ||
import 'zone.js/dist/sync-test.js'; | ||
import 'zone.js/dist/async-test.js'; | ||
import 'zone.js/dist/fake-async-test.js'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { | ||
ServerTestingModule, | ||
platformServerTesting, | ||
} from '@angular/platform-server/testing'; | ||
|
||
// This hack is needed to get jasmine, node and zone working inside bazel. | ||
// 1) we load `jasmine-core` which contains the ENV: it, describe etc... | ||
const jasmineCore: any = require('jasmine-core'); | ||
// 2) We create an instance of `jasmine` ENV. | ||
const patchedJasmine = jasmineCore.boot(jasmineCore); | ||
// 3) Save the `jasmine` into global so that `zone.js/dist/jasmine-patch.js` can get a hold of it to | ||
// patch it. | ||
(global as any)['jasmine'] = patchedJasmine; | ||
// 4) Change the `jasmine-core` to make sure that all subsequent jasmine's have the same ENV, | ||
// otherwise the patch will not work. | ||
// This is needed since Bazel creates a new instance of jasmine and it's ENV and we want to make | ||
// sure it gets the same one. | ||
jasmineCore.boot = function() { | ||
return patchedJasmine; | ||
}; | ||
|
||
require('zone.js/dist/jasmine-patch.js'); | ||
|
||
TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting()); |