Skip to main content

sinew_testing 1.0.0 copy "sinew_testing: ^1.0.0" to clipboard
sinew_testing: ^1.0.0 copied to clipboard

Fakes and test helpers for apps built on Sinew. A dev dependency only.

1.0.0 #

  • mockHttp(…, hooks:): the client is built with devtools' hooks.

  • S5: mockHttp((routes) => routes.on('GET', '/v1/orders').respond(200, body: …, headers: …, delay: …) / .drop(), config:, tokenSource:), a real SinewHttp.dio on a mock adapter that records each request as sent (requests, requestsTo(method, path)), answers a route's responses in order and repeats the last, and drops a connection with the platform adapter's own error (a SocketException; a connectionError on the web). fixture(name) reads test/fixtures/<name> on the VM and fetches it in a browser test, throwing MissingFixture with the path when it's missing. installRecordingReporter() puts the previous reporter back when the test ends, passed or failed. controlledFetch() fails the test when a call is left unanswered.

  • S5: a fake for every Sinew interface: FakeKeyValueStore (a wrong type reads as absent; failNextRead, failNextWrite, failNextWriteWithDiskFull), FakeSecureStore (failNextRead, failNextWrite, loseKey), FakeFieldCipher (no cryptography: a readable enc(…) / enc[context](…) form; failNextDecrypt, rotations), FakeBiometricVault (settable availabilityNow, nextStore / nextUnlock failures, invalidate, prompts), FakeRefreshTokenStore, RecordingCrashReporter (reports, codes, clear) and FakeLocalizer (a map with {name} arguments; the key itself or null when missing; requested), beside FakeTokenSource and FakeNetworkChecker. platformStorageError() and diskFullError() are the PlatformExceptions a storage plugin throws, so an app's processStorageCall classifies a fake's failure as a real one's.

  • S3: FakeNetworkChecker, a network checker the test switches with goOffline() and goOnline().

  • S3: package:sinew_testing/paging.dart, ControlledFetch alone without Flutter, for packages tested with dart test (the network fakes now bring in Flutter through connectivity_plus).

  • S3: FakeTokenSource, a token source the test drives: it counts refreshes and clears, rotates token-1 → token-2, and takes an onRefresh to gate a refresh.

  • S2: ControlledFetch, a paging fetch the test answers call by call.

  • S0: package skeleton.