angular_test 4.0.1
angular_test: ^4.0.1 copied to clipboard
Testing runner and library for AngularDart
4.0.1 #
- Update
README.md
4.0.0 #
- Support null safety
- Require Dart ^2.14.0
3.0.0 #
New Features #
NgTestFixture.dispose()now resets and clears all component styles from the DOM when assertions are enabled.
Breaking Changes #
NgTestBed(the default constructor) is now identical to the behavior ofNgTestBed.forComponentand has replaced it, and the original implementation that usedinitReflector()to load classes based onTypehas been renamed toNgTestBed.useInitReflector.
Bug Fixes #
- Removed
_alwaysStablewhen other stabilizers exist.
2.4.0 #
New Features #
-
Added an optional named parameter,
maxIterations, toFakeTimeNgZoneStabilizer's constructor. If not specified 10 maximum loops are attempted toelapsepending timers. In advanced use cases, a test may configure a higher threshold:NgZoneStabilizer allow100InsteadOf10() { return FakeTimeNgZoneStabilizer(timerZone, ngZone, maxIterations: 100); }
Bug Fixes #
NgTestFixture.update()now delegates toComponentRef.update(), which automatically callsmarkForCheck(). Previously, anOnPushcomponent under test might not have been properly updated.
2.3.1 #
- Maintenance release to support Angular 6.0-alpha.
2.2.0 #
Breaking Changes #
-
Changed
NgTestStabilizerinitialization from originating from aList<NgTestStabilizerFactory>to a singleNgTestStabilizerFactory. The new top-level functioncomposeStabilizersmay be used to create a composite factory from multiple factories:composeStabilizers([ (_) => stabilizer1, (_) => stabilizer2, ])This helps disambiguate the order of stabilizers running, which in turn will allow additional new stabilizers and features to be added in a non-breaking fashion. This change does not impact users that were not augmenting or creating their own stabilizers (i.e. most users/most tests).
-
Removed
NgTestStabilizer.all. SeecomposeStabilizersinstead. -
Removed
NgZoneStabilizer. The new class isRealTimeNgZoneStabilizer, though most users should not be impactedNgTestBednow uses the new stabilizer by default.
New Features #
- Added a new
NgTestStabilizer.alwaysStable, which does what it sounds like and always reports stability. This handles making composition easier as the root stabilizer can effectively be a no-op.
Bug Fixes #
- When using
RealTimeNgZoneStabilizer, do not try to stabilize timers that run outside of Angular zone.
2.1.0 #
New Features #
-
Supported
beforeComponentCreated(Injector)when creating fixture to allow usinginjectorto set up prerequisite data for testing from DI.This is useful when an object (that is already injected to the app) is difficult to create otherwise. For example:
// ComplexDataLayer is difficult to instantiate in test, but it is needed // to set up some fake data before the component is loaded and used. final fixture = await testBed.create( beforeComponentCreated: (i) { var dataLayer = i.get(ComplexDataLayer) as ComplexDataLayer; dataLayer.setUpMockDataForTesting(); }, );
2.0.0 #
New Features #
-
Supported
FutureOr<void>forbeforeChangeDetection. -
NgZoneStabilizerwaits for the longest pending timer duringupdate(). -
Added
isStableAPI toNgTestStabilizer. -
Made
NgTestStabilizerFactorypublic.
Breaking Changes #
-
Removed
throwsInAngular. UsethrowsA. -
Removed
NgTestFixture#query/queryAll, as debug-mode is being turned down. -
Run
DelegatingNgTestStabilizerstabilizers one by one instead of run all at once.update()for each stabilizers will be run at least once. After that, it will only be run if the current stabilizer is not stable. -
pub run angular_testwas entirely removed. Similar functionality is supported out of the box bybuild_runner:
$ pub run build_runner test
-
Removed built-in support for
package:pageloader. The current version ofpageloaderrelies ondart:mirrors, which is being removed from the web compilers (dart2js, dartdevc). There is a new version ofpageloaderin development that uses code generation. We'll consider re-adding support once available or through another package (i.e.angular_pageloaderor similar). -
Adding stabilizers to
NgTestBednow takes a factory function of typeNgTestStabilizer Function(Injector), which is aliased asNgTestStabilizerFactory. This allows usingNgTestBedwithout any dynamic reflective factories (i.e.initReflector()) and doesn't have impact to most users.
Bug Fixes #
-
Deleted an unnecessary
hostElement.append(componentRef.location). -
Fixed a bug where a
WillNeverStabilizeErrorwas thrown whenever there was a non-zero lengthTimerbeing executed. This was due to a bug in how theNgStabilizerwas executing - constantly calling theupdatefunction instead of calling it once and waiting for stabilization. -
Fixed a bug where stabilizers are considered stable even when some of them are not.
-
Fixed a bug where
_createDynamicdoes not preserverootInjector. -
Added
NgTestBed.forComponent, which takes aComponentFactory<T>, and optionally anInjectorFactory. This allows writing tests entirely free of any invocations ofinitReflector().
1.0.0 #
Breaking Changes & Deprecations #
-
Throws in bootstrapping if the root component does not use default change detection. AngularDart does not support
OnPushor other change detection strategies on the root component. -
Pub serve now defaults to a random unused port (instead of
8080) and--portis deprecated. Going forward the supported way to supply this argument is via--serve-arg:
$ pub run angular_test --serve-arg=port=1234
- Option
--run-test-flag(-t) is now deprecated, and no longer has a default value ofaot. Tags are still highly encouraged in order to have faster compilation times! Use--test-arginstead:
$ pub run angular_test --test-arg=--tags=aot
- Option
--platform(-p) is now Deprecated, and no longer has a default value ofcontent-shell, which was not always installed on host machines. Instead use--test-arg:
$ pub run angular_test --test-arg=--platform=content-shell
-
Option
--name(-n) and--simple-name(-N) are also deprecated. Use--test-arg=--name=and--test-arg=--simple-name=instead. -
Changes to
compatibility.dartmight not be considered in future semver updates, and it highly suggested you don't use these APIs for any new code. -
Change
NgTestFixture.updateto have a single optional parameter
Features #
-
Add assertOnlyInstance to fixture to remove some boilerplate around testing the state of a instance. Only use to test state, not to update it.
-
Added
--serve-argand--test-arg, which both support multiple arguments in order to have better long-term support for proxying to bothpub serveandpub run testwithout frequent changes to this package. For example to use the [DartDevCompiler (dartdevc)]:
$ pub run angular_test --serve-arg=web-compiler=dartdevc
- Add support for setting a custom
PageLoaderfactory:
testBed = testBed.setPageLoader(
(element) => new CustomPageLoader(...),
);
- Add support for
queryandqueryAlltoNgTestFixture. This works similar to theupdatecommand, but is called back with either a single or multiple child component instances to interact with or run expectations against:
// Assert we have 3 instances of <child>.
await fixture.queryAll(
(el) => el.componentInstance is ChildComponent,
(children) {
expect(children, hasLength(3));
},
);
- Add built-in support for
package:pageloader:
final fixture = await new NgTestBed<TestComponent>().create();
final pageObject = await fixture.getPageObject/*<ClickCounterPO>*/(
ClickCounterPO,
);
expect(await pageObject.button.visibleText, 'Click count: 0');
await pageObject.button.click();
expect(await pageObject.button.visibleText, 'Click count: 1');
Fixes #
-
Workaround for
pub {serve|build}hanging onangular_testas a dependency. -
Fixes a bug where the root was not removed from the DOM after disposed.
-
Added a missing dependency on
package:func. -
Properly fix support for windows by using
pub.bat. -
Replace all uses of generic comment with proper syntax.
-
Fixed a bug where
activeTestwas never set (and therefore disposed). -
Fixed a bug where
pub, notpub.bat, is run in windows. -
Update
pubspec.yamlso it properly lists AngularDart3.0.0-alpha -
Fix the executable so
pub run angular_testcan be used -
Fix a serious generic type error when
NgTestBedis forked -
Fix a generic type error
-
Added
compatibility.dart, a temporary API to some users migrate