forked from ngrx/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): Add Store unit tests to Bazel (ngrx#836)
- Loading branch information
1 parent
3e31894
commit 31d24e8
Showing
12 changed files
with
142 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,8 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//tools:defaults.bzl", "ts_test_library") | ||
|
||
ts_test_library( | ||
name = "node", | ||
srcs = ["bootstrap_node_tests.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,33 @@ | ||
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'; | ||
|
||
const jasmineCore: any = require('jasmine-core'); | ||
const patchedJasmine = jasmineCore.boot(jasmineCore); | ||
(global as any)['jasmine'] = patchedJasmine; | ||
|
||
jasmineCore.boot = function() { | ||
return patchedJasmine; | ||
}; | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
import { | ||
ServerTestingModule, | ||
platformServerTesting, | ||
} from '@angular/platform-server/testing'; | ||
|
||
require('zone.js/dist/jasmine-patch.js'); | ||
|
||
const originalConfigureTestingModule = TestBed.configureTestingModule; | ||
|
||
TestBed.configureTestingModule = function() { | ||
TestBed.resetTestingModule(); | ||
|
||
return originalConfigureTestingModule.apply(null, arguments); | ||
}; | ||
|
||
TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting()); |