getTestFileResolver function
- @visibleForTesting
Creates a PackageFileResolverImpl for tests.
The resolver maps the test package to testFilePath and uses the provided
config for other package mappings.
Implementation
@visibleForTesting
/// Creates a [PackageFileResolverImpl] for tests.
///
/// The resolver maps the test package to [testFilePath] and uses the provided
/// [config] for other package mappings.
PackageFileResolverImpl getTestFileResolver() {
final testFilePath = Uri.file('/${StringAsset.testPackageName}');
final String configUri = p.join(p.current, packageConfigLocation);
final PackageConfig config = PackageFileResolverImpl.loadPackageConfig(configUri);
final fileResolver = PackageFileResolverImpl(
{
StringAsset.testPackageName: testFilePath.toString(),
...config.packageToPath,
},
packagesHash: config.packagesHash,
rootPackage: rootPackageName,
);
return fileResolver;
}