felangel / felangel/mocktail

mocktail could offer string diffs on call failures?

Open
#208 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
702
Forks
88
PR merge metrics
No merged PRs in 30d

Description

For long strings it can be very hard to figure out how to match calls exactly. e.g.:
```dart
verify(
() => logger.info('''

Your next step is to upload the app bundle to the Play Store:
build/app/outputs/bundle/release/app-release.aab

Or distribute the apk:
build/app/outputs/apk/release/app-release.apk

For information on uploading to the Play Store, see:
${link(uri: Uri.parse('https://support.google.com/googleplay/android-developer/answer/9859152?hl=en'))}
'''),
```

I get the message:
```
00:01 +304 ~1 -1: test/src/commands/release/release_android_command_test.dart: ReleaseAndroidCommand succeeds when release is successful (with apk) [E]
No matching calls. All calls: _MockLogger.progress(Building release, {options: null}),
_MockLogger.progress(Detecting release version, {options: null}),
_MockLogger.info(

🚀 Ready to create a new release!

📱 App: Test App (test-app-id)
📦 Release Version: 1.2.3+1
🕹️ Platform: android (arm64, arm32, x86_64)
, {style: null}),
_MockLogger.confirm(Would you like to continue?, {defaultValue: false}),
[VERIFIED] _MockLogger.success(

✅ Published Release!, {style: null}),
_MockLogger.info(

Your next step is to upload the app bundle to the Play Store:
build/app/outputs/bundle/release/app-release.aab

Or distribute the apk:
build/app/outputs/apk/release/app-release.apk

For information on uploading to the Play Store, see:
https://support.google.com/googleplay/android-developer/answer/9859152?hl=en
, {style: null})
(If you called `verify(...).called(0);`, please instead use `verifyNever(...);`.)
package:matcher fail
package:mocktail/src/mocktail.dart 728:7 _VerifyCall._checkWith
package:mocktail/src/mocktail.dart 519:18 _makeVerify.
test/src/commands/release/release_android_command_test.dart 374:13 main..
```

I'm clearly very close, but not quite right yet. Mocktail could theoretically detect this and offer me a string difference to help see where my error is. 🤷 That may be out of scope for mocktail though.

package:test has some decent string diffing code (I even used it in a recent fun project):
https://github.com/dart-lang/test/blob/2cb07a3f4d16b74f1181bd8f963d342db5a8e6b0/pkgs/checks/lib/src/extensions/string.dart

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.