fixture reader can't open file
pratamawijaya opened this issue · 2 comments
pratamawijaya commented
i'm trying running test with
flutter test
but it show error
test/features/number_trivia/data/models/number_trivia_model_test.dart:
fromJson should return a valid model when the JSON number is an integer [E]
FileSystemException: Cannot open file, path = 'test/fixtures/trivia.json'
(OS Error: No such file or directory, errno = 2)
dart:io File.readAsStringSync
fixtures/fixture_reader.dart 3:60 fixture
features/number_trivia/data/models/number_trivia_model_test.dart 26:25 main.<fn>.<fn>
sophiabrandt commented
If someone has the same problem:
it looks like only VSCode can find the file path of the test file.
If you're using a different editor, fix the file fixture_reader.dart
like so:
import 'dart:io';
String fixture(String name) {
var dir = Directory.current.path;
if (dir.endsWith('/test')) {
dir = dir.replaceAll('/test', '');
}
return File('$dir/test/fixtures/$name').readAsStringSync();
}
More information on this GitHub issue.