angular_test 1.0.1

  • Installing
  • Versions
  • 97

Pub package

Testing infrastructure and runner for AngularDart, used with the test package.

Documentation and examples:

Additional resources:


angular_test is both a framework for writing tests for AngularDart components and a test runner that delegates to pub serve and pub run test to run component tests using the AOT compiler.

Note: angular_test does not function in reflective mode.

Here's an example of an AngularDart test:

@Tags(const ['aot'])
import 'dart:html';

import 'package:angular/angular.dart';
import 'package:angular_test/angular_test.dart';
import 'package:test/test.dart';

void main() {

  test('should render "Hello World"', () async {
    final testBed = new NgTestBed<HelloWorldComponent>();
    final testFixture = await testBed.create();
    expect(testFixture.text, 'Hello World');
    await testFixture.update((c) => = 'Universe');
    expect(testFixture.text, 'Hello Universe');

@Component(selector: 'test', template: 'Hello {{name}}')
class HelloWorldComponent {
  String name = 'World';

To use angular_test, configure your package's pubspec.yaml as follows:

  # Run the code generator on the entire package.
  - angular/transform/codegen

  # Run the reflection remover on tests that have AOT enabled.
  - angular/transform/reflection_remover:
          - test/test_using_angular_test.dart

  # Allow test to proxy-load files so we can run AOT tests with pub serve.
  - test/pub_serve:
      $include: test/**_test.dart

To run tests, use pub run angular_test. It automatically runs pub serve to run code generation (transformers) and pub run test to run browser tests on anything tagged with 'aot'. Also declare a specific browser test platform, as described in the test package description; dartium and content-shell are the most common choices. Here's an example of running tests using the content shell:

pub run angular_test --test-arg=--tags=aot --test-arg=--platform=content-shell


The angular_test script can accept the following options:

--package              What directory containing a pub package to run tests in
                       (defaults to CWD)

-v, --[no-]verbose     Whether to display output of "pub serve" while running tests
    --help             Show usage
    --port             What port to use for pub serve.

                       **DEPRECATED**: Use --serve-arg=--port=.... If this is
                       not specified, and --serve-arg=--port is not specified, then
                       defaults to a value of "0" (or random port).

-S, --serve-arg        Pass an additional argument=value to `pub serve`

                       Example use --serve-arg=--mode=release

-t, --run-test-flag    What flag(s) to include when running "pub run test".
                       In order to have a fast test cycle, we only want to run
                       tests that have Angular compilation required (all the ones
                       created using this package do).

                       **DEPRECATED**: Use --test-arg=--tags=... instead

-p, --platform         What platform(s) to pass to `pub run test`.

                       **DEPRECATED**: Use --test-arg=--platform=... instead

-n, --name             A substring of the name of the test to run.
                       Regular expression syntax is supported.
                       If passed multiple times, tests must match all substrings.

                       **DEPRECATED**: Use --test-arg=--name=... instead

-N, --plain-name       A plain-text substring of the name of the test to run.
                       If passed multiple times, tests must match all substrings.

                       **DEPRECATED**: Use --test-arg=--plain-name=... instead

-T, --test-arg         Pass an additional argument=value to `pub run test`

                       Example: --test-arg=--name=ngIf



  • Remove dependency on angular_router.


Breaking Changes & Deprecations

  • Throws in bootstrapping if the root component does not use default change detection. AngularDart does not support OnPush or other change detection strategies on the root component.

  • Pub serve now defaults to a random unused port (instead of 8080) and --port is 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 of aot. Tags are still highly encouraged in order to have faster compilation times! Use --test-arg instead:
$ pub run angular_test --test-arg=--tags=aot
  • Option --platform (-p) is now Deprecated, and no longer has a default value of content-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.dart might not be considered in future semver updates, and it highly suggested you don't use these APIs for any new code.

  • Change NgTestFixture.update to have a single optional parameter


  • 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-arg and --test-arg, which both support multiple arguments in order to have better long-term support for proxying to both pub serve and pub run test without 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 PageLoader factory:
testBed = testBed.setPageLoader(
  (element) => new CustomPageLoader(...),
  • Add support for query and queryAll to NgTestFixture. This works similar to the update command, 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>*/(
expect(await pageObject.button.visibleText, 'Click count: 0');
expect(await pageObject.button.visibleText, 'Click count: 1');


  • Workaround for pub {serve|build} hanging on angular_test as 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 activeTest was never set (and therefore disposed).

  • Fixed a bug where pub, not pub.bat, is run in windows.

  • Update pubspec.yaml so it properly lists AngularDart 3.0.0-alpha

  • Fix the executable so pub run angular_test can be used

  • Fix a serious generic type error when NgTestBed is forked

  • Fix a generic type error

  • Added compatibility.dart, a temporary API to some users migrate

1. Depend on it

Add this to your package's pubspec.yaml file:

  angular_test: "^1.0.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:angular_test/angular_test.dart';
Version Uploaded Documentation Archive
1.0.1 Sep 25, 2017 Go to the documentation of angular_test 1.0.1 Download angular_test 1.0.1 archive
1.0.0 Aug 30, 2017 Go to the documentation of angular_test 1.0.0 Download angular_test 1.0.0 archive
2.0.0-alpha+2 Jan 18, 2018 Go to the documentation of angular_test 2.0.0-alpha+2 Download angular_test 2.0.0-alpha+2 archive
2.0.0-alpha+1 Jan 8, 2018 Go to the documentation of angular_test 2.0.0-alpha+1 Download angular_test 2.0.0-alpha+1 archive
2.0.0-alpha Dec 19, 2017 Go to the documentation of angular_test 2.0.0-alpha Download angular_test 2.0.0-alpha archive
1.0.2-alpha+1 Nov 21, 2017 Go to the documentation of angular_test 1.0.2-alpha+1 Download angular_test 1.0.2-alpha+1 archive
1.0.2-alpha Oct 10, 2017 Go to the documentation of angular_test 1.0.2-alpha Download angular_test 1.0.2-alpha archive
1.0.0-beta+5 Aug 7, 2017 Go to the documentation of angular_test 1.0.0-beta+5 Download angular_test 1.0.0-beta+5 archive
1.0.0-beta+4 Jul 11, 2017 Go to the documentation of angular_test 1.0.0-beta+4 Download angular_test 1.0.0-beta+4 archive
1.0.0-beta+3 Jun 16, 2017 Go to the documentation of angular_test 1.0.0-beta+3 Download angular_test 1.0.0-beta+3 archive

All 15 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Jan 21, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.10.0


Describes how popular the package is relative to other packages. [more]
95 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: web

Primary library: package:angular_test/angular_test.dart.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use angular_test.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
angular ^4.0.0 4.0.0+2 5.0.0-alpha+4
ansicolor ^0.0.9 0.0.9
args ^0.13.7 0.13.7 1.2.0
collection ^1.14.0 1.14.5
func >=0.1.1 <2.0.0 1.0.0
logging ^0.11.3+1 0.11.3+1
matcher ^0.12.0+2 0.12.1+4
meta ^1.0.0 1.1.2
pageloader ^2.2.5 2.2.6
path ^1.4.1 1.5.1
stack_trace ^1.7.0 1.9.1
test ^0.12.17 0.12.30
Transitive dependencies
analyzer 0.30.0+4 0.31.0-alpha.2
angular_compiler 0.3.0+1 0.4.0-alpha+4
archive 1.0.33
async 2.0.3
barback 0.15.2+14
boolean_selector 1.0.2
build 0.11.2 0.12.0
build_barback 0.4.0+2 0.5.0+2
charcode 1.1.1
cli_util 0.1.2+1
code_builder 1.0.4 3.0.0
code_transformers 0.5.1+3
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
dart_style 1.0.9
front_end 0.1.0-alpha.4.1 0.1.0-alpha.7
glob 1.1.5
html 0.13.2+2
http 0.11.3+16
http_multi_server 2.0.4
http_parser 3.1.1
intl 0.15.2
io 0.3.1
isolate 1.1.0
js 0.6.1
kernel 0.3.0-alpha.1.1 0.3.0-alpha.4
mime 0.9.5
multi_server_socket 1.0.1
node_preamble 1.4.0
package_config 1.0.3
package_resolver 1.0.2
plugin 0.2.0+2
pool 1.3.4
pub_semver 1.3.2
quiver 0.25.0 0.28.0
quiver_hashcode 1.0.0
shelf 0.7.2
shelf_packages_handler 1.0.3
shelf_static 0.2.7
shelf_web_socket 0.2.2
source_gen 0.7.4
source_map_stack_trace 1.1.4
source_maps 0.10.4
source_span 1.4.0
stream_channel 1.6.3
string_scanner 1.0.2
term_glyph 1.0.0
tuple 1.0.1
typed_data 1.1.5
unittest 0.11.7 0.12.4+1
utf 0.9.0+3
watcher 0.9.7+6
web_socket_channel 1.0.6
webdriver 1.2.3 2.0.0-beta
yaml 2.1.13