Skip to content

[BUG] [Dart] dev_dependency test package is too outdated to run on Dart 3+ projects #17563

@0xNF

Description

@0xNF

Dart2 generates a pubspec file with

dev_dependencies:
  test: '>=1.16.0 <1.18.0'

as one of its dependencies. This package provides testing capabilities.

However, users with Dart 3 installed will find that their tests are incapable of being run. Any attempts to run a test will fail with this error message:

LoadException (Failed to load "$project\test\some_generated_file_test.dart":
../../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.11/lib/src/error_matchers.dart:14:33: Error: 'CastError' isn't a type.
const isCastError = TypeMatcher<CastError>();
                                ^^^^^^^^^
../../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.11/lib/src/error_matchers.dart:21:49: Error: 'CyclicInitializationError' isn't a type.
const isCyclicInitializationError = TypeMatcher<CyclicInitializationError>();
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.11/lib/src/error_matchers.dart:33:39: Error: 'NullThrownError' isn't a type.
const isNullThrownError = TypeMatcher<NullThrownError>();
                                      ^^^^^^^^^^^^^^^)

Solution

Bumping the minimum version to 1.21.6 minimum will cause the tests to load and run fine, but this requires that a minimum of Dart 2.18, up from the current 2.12, to be installed on the user's machine, according to the test package changelog:

https://pub.dev/packages/test/changelog#1216

# 1.21.6 
* Require Dart >= 2.18.0
* Support the latest `package:test_api` and `package:test_core`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions