ngtest 4.1.1 copy "ngtest: ^4.1.1" to clipboard
ngtest: ^4.1.1 copied to clipboard

Platformweb

Testing runner and library for AngularDart. This package is necessary to write component tests for AngularDart components.

Pub package Build Status Gitter

Testing infrastructure for AngularDart, used with the build_runner package.

See https://github.com/angulardart-community for current updates on this project.

Documentation and examples:

  • _tests/test/ (tests for the main dart-lang/angular package)

Additional resources:

Overview #

ngtest is a library for writing tests for AngularDart components.

// Assume this is 'my_test.dart'.
import 'my_test.template.dart' as ng;

void main() {
  ng.initReflector();
  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';
}

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

# Use the latest versions if possible.
dev_dependencies:
  build_runner: ^2.0.0
  build_test: ^2.0.0
  build_web_compilers: ^3.0.0

IMPORTANT: ngtest will not run without these dependencies set.

To run tests, use pub run build_runner test. It automatically compiles your templates and annotations with AngularDart, and then compiles all of the Dart code to JavaScript in order to run browser tests. Here's an example of using Chrome with Dartdevc:

pub run build_runner test -- -p chrome

For more information using pub run build_runner test, see the documentation: https://github.com/dart-lang/build/tree/master/build_runner#built-in-commands

3
likes
110
pub points
62%
popularity

Publisher

verified publisherangulardart.xyz

Testing runner and library for AngularDart. This package is necessary to write component tests for AngularDart components.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

collection, meta, ngdart

More

Packages that depend on ngtest