test_html_builder 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

test_html_builder #

A Dart builder that uses templates to generate HTML files for dart tests. Useful for projects with many tests that require custom HTML. Instead of having to replicate the custom HTML file for every test file that requires it, this builder can apply a template to any number of test files.

Usage #

Add this package as a dev_dependency:

  test_html_builder: ^1.0.0

Create as many HTML test templates in the test/ directory as needed, e.g.:

<!-- test/example_template.html -->
        <!-- Load custom assets needed by the test. -->
        <script src="custom.js"></script>

        <!-- Every template must include this token. -->
        <!-- It will be replaced by the builder with the required tags:
        <link rel="x-dart-test" href="...">
        <script src="packages/test/dart.js"></script>

Tell the builder which templates should be applied to which files, e.g.:

              - "test/components/styled/**_test.dart"
              - "test/components/**_test.dart"

To illustrate how this works, consider an example test directory structure:

  • test/
    • foo_test.dart
    • react_template.html
    • react_with_styles_template.html
    • components/
      • bar_test.dart
      • styled/
        • baz_test.dart

Running tests via pub run build_runner test with the above configuration will result in the following (hidden) generated outputs:

  • test/components/bar_test.html (from react_template.html)
  • test/components/styled/baz_test.html (from react_with_styles_template.html)

Notes #

  • If there is overlap between the globs defined for multiple templates, the builder will choose the first template that matches.

  • If none of the templates match for a given test file, no html file will be generated.

  • One-off custom html files for individual tests are still supported, but they must use the .custom.html extension:

    • test/example_test.dart
    • test/example_test.custom.html

Contributing #

See the Contributing Guidelines.

1.0.2 #

  • Fix #8.

  • Address pub health/maintenance recommendations (add an example, add missing doc comments).

1.0.1 #

  • Update package metadata in pubspec.yaml.

1.0.0 #

  • Initial version.


Example #

The project/ directory contains an example project that consumes this test_html_builder. You should be able to run tests in this directory via pub run build_runner test and have them all pass.

Use this package as a library

1. Depend on it

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

  test_html_builder: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:test_html_builder/builder.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
build ^1.1.4 1.2.2
build_config >=0.3.0 <0.5.0 0.4.1+1
glob ^1.1.7 1.2.0
json_annotation ^3.0.0 3.0.1
logging ^0.11.3+2 0.11.4
path ^1.6.4 1.6.4
Transitive dependencies
_fe_analyzer_shared 1.0.3
analyzer 0.39.4
args 1.5.2
async 2.4.0
charcode 1.1.2
checked_yaml 1.0.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
html 0.14.0+3
js 0.6.1+1
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pub_semver 1.4.2
pubspec_parse 0.1.5
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
build_runner ^1.3.0
build_test ^0.10.7+3
build_web_compilers ^2.3.0
dependency_validator ^1.2.0
pedantic ^1.8.0 1.9.0
test ^1.6.3