Each package may include a configuration file that applies to the package as a whole. This file can be used to provide custom defaults for various options, to define configuration for multiple files, and more.

The file is named dart_test.yaml and lives at the root of the package, next to the package‘s pubspec. Like the pubspec, it’s a YAML file. Here's an example:

# This package's tests are very slow. Double the default timeout.
timeout: 2x

# This is a browser-only package, so test on content shell by default.
platforms: [content-shell]

tags:
  # Integration tests are even slower, so increase the timeout again.
  integration: {timeout: 2x}

  # Sanity tests are quick and verify that nothing is obviously wrong. Declaring
  # the tag allows us to tag tests with it without getting warnings.
  sanity:

Test Configuration

There are two major categories of configuration field: “test” and “runner”. Test configuration controls how individual tests run, while runner configuration controls the test runner as a whole. Both types of fields may be used at the top level of a configuration file. However, because different tests can have different test configuration, only test configuration fields may be used to configure tags.

timeout

This field indicates how much time the test runner should allow a test to remain inactive before it considers that test to have failed. It has three possible formats:

  • The string “none” indicates that tests should never time out.

  • A number followed by a unit abbreviation indicates an exact time. For example, “1m” means a timeout of one minute, and “30s” means a timeout of thirty seconds. Multiple numbers can be combined, as in “1m 30s”.

  • A number followed by “x” indicates a multiple. This is applied to the default value of 30s.

timeout: 1m

verbose_trace

This boolean field controls whether or not stack traces caused by errors are trimmed to remove internal stack frames. This includes frames from the Dart core libraries, the stack_trace package, and the test package itself. It defaults to false.

verbose_trace: true

js_trace

This boolean field controls whether or not stack traces caused by errors that occur while running Dart compiled to JS are converted back to Dart style. This conversion uses the source map generated by dart2js to approximate the original Dart line, column, and in some cases member name for each stack frame. It defaults to false.

js_trace: true

skip

This field controls whether or not tests are skipped. It‘s usually applied to specific tags rather than used at the top level. Like the skip parameter for test(), it can either be a boolean indicating whether the tests are skipped or a string indicating the reason they’re skipped.

tags:
  chrome:
    skip: "Our Chrome launcher is busted. See issue 1234."

test_on

This field declares which platforms a test supports. It takes a platform selector and only allows tests to run on platforms that match the selector. It's often used with specific tags to ensure that certain features will only be tested on supported platforms.

tags:
  # Internet Explorer doesn't support promises yet.
  promises: {test_on: "browser && !ie"}

The field can also be used at the top level of the configuration file to indicate that the entire package only supports a particular platform. If someone tries to run the tests on an unsupported platform, the runner will print a warning and skip that platform.

# This package uses dart:io.
test_on: vm

Runner Configuration

Unlike test configuration, runner configuration affects the test runner as a whole rather than individual tests. It can only be used at the top level of the configuration file.

paths

This field indicates the default paths that the test runner should run. These paths are usually directories, although single filenames may be used as well. Paths must be relative, and they must be in URL format so that they're compatible across operating systems. This defaults to [test].

paths: [dart/test]

paths:
- test/instantaneous
- test/fast
- test/middling

filename

This field indicates the filename pattern that the test runner uses to find test files in directories. All files in directories passed on the command line (or in directories in paths, if none are passed) whose basenames match this pattern will be loaded and run as tests.

This supports the full glob syntax. However, since it‘s only compared against a path’s basename, path separators aren't especially useful. It defaults to "*_test.dart".

filename: "test_*.dart"

platforms

This field indicates which platforms tests should run on by default. It allows the same platform identifiers that can be passed to --platform. If multiple platforms are included, the test runner will default to running tests on all of them. This defaults to [vm].

platforms: [content_shell]

platforms:
- chrome
- firefox

concurrency

This field indicates the default number of test suites to run in parallel. More parallelism can improve the overall speed of running tests up to a point, but eventually it just adds more memory overhead without any performance gain. This defaults to approximately half the number of processors on the current machine. If it's set to 1, only one test suite will run at a time.

concurrency: 3

pub_serve

This field indicates that the test runner should run against a pub serve instance by default, and provides the port number for that instance. Note that if there is no pub serve instance running at that port, running the tests will fail by default.

pub_serve: 8081

reporter

This field indicates the default reporter to use. It may be set to “compact”, “expanded”, or “json” (although why anyone would want to default to JSON is beyond me). It defaults to “expanded” on Windows and “compact” everywhere else.

reporter: expanded

Configuring Tags

The tag field can be used to apply test configuration to all tests with a given tag or set of tags. It takes a map from tag selectors to configuration maps. These configuration maps are just like the top level of the configuration file, except that they may not contain runner configuration.

tags:
  # Integration tests need more time to run.
  integration:
    timeout: 1m

Tags may also have no configuration associated with them. The test runner prints a warning whenever it encounters a tag it doesn't recognize, and this the best way to tell it that a tag exists.

# We occasionally want to use --tags or --exclude-tags on these tags.
tags:
  # A test that spawns a browser.
  browser:

  # A test that needs Ruby installed.
  ruby:

You can also use boolean selector syntax to define configuration that involves multiple tags. For example:

tags:
  # Tests that invoke sub-processes tend to be a little slower.
  ruby || python:
    timeout: 1.5x

Tag configuration is applied at whatever level the tag appears—so if a group is tagged as integration, its timeout will take precedence over the suite‘s timeout but not any tests’. If the group itself had a timeout declared, the group's explicit timeout would take precedence over the tag.

If multiple tags appear at the same level, and they have conflicting configurations, the test runner does not guarantee what order they‘ll be resolved in. In practice, conflicting configuration is pretty unlikely and it’s easy to just explicitly specify what you want on the test itself.

add_tags

This field adds additional tags. It‘s technically test configuration, but it’s usually used in more specific contexts. For example, when included in a tag's configuration, it can be used to enable tag inheritance, where adding one tag implicitly adds other as well. It takes a list of tag name strings.

tags:
  # Any test that spawns a browser.
  browser:
    timeout: 2x

  # Tests that spawn specific browsers. These automatically get the browser tag
  # as well.
  chrome: {add_tags: [browser]}
  firefox: {add_tags: [browser]}
  safari: {add_tags: [browser]}
  ie: {add_tags: [browser]}