angular_test 1.0.0-beta+1

  • Readme
  • Changelog
  • Installing
  • --

angular_test #

Testing infrastructure and runner for AngularDart.

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:angular2/angular2.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.
  - angular2/transform/codegen

  # Run the reflection remover on tests that have AoT enabled.
  - angular2/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'.:

$ pub run angular_test

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+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';
  
Awaiting analysis to complete.