angular2_testing 2.0.0-beta.17

  • Installing
  • Versions
  • 38

Contains helpers to run unit tests for angular2 components and injectables, backed by the package:test library.


Update the dev dependencies in your pubspec.yaml to include the angular testing and test packages:

  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.

  // 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) {

  ngTest('can grab injected values', (@Inject(MyToken) token, TestService testService) {
    expect(token, equals('my string'));
    expect(testService.status, equals('ready'));


A sample test is available in test/angular2_testing_test.dart.

1. Depend on it

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

  angular2_testing: "^2.0.0-beta.17"

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:angular2_testing/angular2_testing.dart';
Version Uploaded Documentation Archive
2.0.0-beta.17 Apr 28, 2016 Go to the documentation of angular2_testing 2.0.0-beta.17 Download angular2_testing 2.0.0-beta.17 archive
2.0.0-beta.16 Apr 26, 2016 Go to the documentation of angular2_testing 2.0.0-beta.16 Download angular2_testing 2.0.0-beta.16 archive
2.0.0-beta.15 Apr 13, 2016 Go to the documentation of angular2_testing 2.0.0-beta.15 Download angular2_testing 2.0.0-beta.15 archive
2.0.0-beta.14 Apr 7, 2016 Go to the documentation of angular2_testing 2.0.0-beta.14 Download angular2_testing 2.0.0-beta.14 archive
2.0.0-beta.13 Mar 31, 2016 Go to the documentation of angular2_testing 2.0.0-beta.13 Download angular2_testing 2.0.0-beta.13 archive
2.0.0-beta.12 Mar 24, 2016 Go to the documentation of angular2_testing 2.0.0-beta.12 Download angular2_testing 2.0.0-beta.12 archive
2.0.0-beta.11 Mar 18, 2016 Go to the documentation of angular2_testing 2.0.0-beta.11 Download angular2_testing 2.0.0-beta.11 archive
2.0.0-beta.10 Mar 17, 2016 Go to the documentation of angular2_testing 2.0.0-beta.10 Download angular2_testing 2.0.0-beta.10 archive
2.0.0-beta.9 Mar 9, 2016 Go to the documentation of angular2_testing 2.0.0-beta.9 Download angular2_testing 2.0.0-beta.9 archive
2.0.0-beta.8 Mar 2, 2016 Go to the documentation of angular2_testing 2.0.0-beta.8 Download angular2_testing 2.0.0-beta.8 archive

All 25 versions...


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

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

  • tool failures on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


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


Detected platforms: unsure

Error(s) prevent platform classification.


  • Fix dependencies in pubspec.yaml.

    Running pub upgrade failed with the following output:

    Exceeded timeout of 0:02:00.000000
  • Fix platform conflicts.

    Make sure none of the libraries use mutually exclusive dependendencies.

  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • 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 angular2_testing.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.10.0 <2.0.0