angular_test 1.0.0-beta+5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 46

angular_test

Pub Package

Testing infrastructure and runner for AngularDart.

It's strongly recommended to view the test/ folder for examples and recommended patterns.

Usage

angular_test is both a framework for writing tests for AngularDart components and a test runner that delegates to both pub serve and pub run test to run component tests using the AOT-compiler - angular_test does not function in reflective mode.

Example use:

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

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

@AngularEntrypoint()
void main() {
  tearDown(disposeAnyRunningTest);

  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) => c.name = 'Universe');
    expect(testFixture.text, 'Hello Universe');
  });
}

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

You will need to also configure in pubspec.yaml to run code generation:

transformers:
  # 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:
      $include:
          - test/test_using_angular_test.dart

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

Running

Use pub run angular_test - it will automatically run pub serve to run code generation (transformers) and pub run test to run browser tests on anything tagged with 'aot'. You'll also need to declare a specific browser test platform: dartium or content-shell are the most common choices. For example:

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

Use one or more

  • --test-arg to pass arguments to pub run test
  • --serve-arg to pass arguments to pub serve

Usage

--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

1.0.0-beta+5

  • Workaround for pub {serve|build} hanging on angular_test as a dependency.

1.0.0-beta+4

Now supports package:angular instead of package:angular2.

1.0.0-beta+3

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.

Features

  • 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

Fixes

  • Fixes a bug where the root was not removed from the DOM after disposed.

  • Added a missing dependency on package:func.

1.0.0-beta+2

  • 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));
  },
);

1.0.0-beta+1

  • Properly fix support for windows by using pub.bat.

1.0.0-beta

  • Prepare to support angular2: 3.0.0-beta.
  • 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.

1.0.0-alpha+6

  • Address breaking changes in angular2: 3.0.0-alpha+1.

1.0.0-alpha+5

  • Update pubspec.yaml to tighten the constraint on AngularDart

1.0.0-alpha+4

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

1.0.0-alpha+3

  • Fix the executable so pub run angular_test can be used

1.0.0-alpha+2

  • 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');
  • 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

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.

1.0.0-alpha+1

  • Change NgTestFixture.update to have a single optional parameter

1.0.0-alpha

  • Initial commit with compatibility for AngularDart 2.2.0

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate angular_test

2. Use it

The package has the following executables:


$ angular_test

Use this package as a library

1. Depend on it

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


dependencies:
  angular_test: ^1.0.0-beta+5

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
2.0.0 Aug 7, 2018 Go to the documentation of angular_test 2.0.0 Download angular_test 2.0.0 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-beta+3 Aug 2, 2018 Go to the documentation of angular_test 2.0.0-beta+3 Download angular_test 2.0.0-beta+3 archive
2.0.0-beta+2 Jul 19, 2018 Go to the documentation of angular_test 2.0.0-beta+2 Download angular_test 2.0.0-beta+2 archive
2.0.0-beta+1 Jul 16, 2018 Go to the documentation of angular_test 2.0.0-beta+1 Download angular_test 2.0.0-beta+1 archive
2.0.0-beta Jun 29, 2018 Go to the documentation of angular_test 2.0.0-beta Download angular_test 2.0.0-beta archive
2.0.0-alpha+13 Jun 15, 2018 Go to the documentation of angular_test 2.0.0-alpha+13 Download angular_test 2.0.0-alpha+13 archive
2.0.0-alpha+12 Jun 5, 2018 Go to the documentation of angular_test 2.0.0-alpha+12 Download angular_test 2.0.0-alpha+12 archive
2.0.0-alpha+11 May 24, 2018 Go to the documentation of angular_test 2.0.0-alpha+11 Download angular_test 2.0.0-alpha+11 archive

All 31 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

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