2b34c88b69
BREAKING CHANGE: - Renderer: * renderComponent method is removed form `Renderer`, only present on `RootRenderer` * Renderer.setDebugInfo is removed. Renderer.createElement / createText / createTemplateAnchor now take the DebugInfo directly. - Query semantics: * Queries don't work with dynamically loaded components. * e.g. for router-outlet: loaded components can't be queries via @ViewQuery, but router-outlet emits an event `activate` now that emits the activated component - Exception classes and the context inside changed (renamed fields) - DebugElement.attributes is an Object and not a Map in JS any more - ChangeDetectorGenConfig was renamed into CompilerConfig - AppViewManager.createEmbeddedViewInContainer / AppViewManager.createHostViewInContainer are removed, use the methods in ViewContainerRef instead - Change detection order changed: * 1. dirty check component inputs * 2. dirty check content children * 3. update render nodes Closes #6301 Closes #6567 |
||
---|---|---|
.. | ||
lib | ||
test | ||
README.md | ||
pubspec.yaml |
README.md
Contains helpers to run unit tests for angular2 components and injectables,
backed by the package:test
library.
Usage
Update the dev dependencies in your pubspec.yaml
to include the angular testing
and test packages:
dev_dependencies:
test: '^0.12.6'
angular2_testing: any
Then in your test files, use angular2_testing helpers in place of setUp
and test
:
import 'package:test/test.dart';
import 'package:angular2_testing/angular2_testing.dart';
void main() {
// This must be called at the beginning of your tests.
initAngularTests();
// Initialize the injection tokens you will use in your tests.
setUpProviders(() => [provide(MyToken, useValue: 'my string'), TestService]);
// You can then get tokens from the injector via ngSetUp and ngTest.
ngSetUp((TestService testService) {
testService.initialize();
});
ngTest('can grab injected values', (@Inject(MyToken) token, TestService testService) {
expect(token, equals('my string'));
expect(testService.status, equals('ready'));
});
}
Examples
A sample test is available in test/angular2_testing_test.dart
.