Skip to main content

netlens_test 1.1.0 copy "netlens_test: ^1.1.0" to clipboard
netlens_test: ^1.1.0 copied to clipboard

Test matchers and mocks for writing and testing adapters of the NetLens in-app HTTP inspector.

example/README.md

NetLens Test example #

Mock the NetLens core and check the calls that your adapter adds to it.

import 'package:mocktail/mocktail.dart';
import 'package:netlens/core/netlens_core.dart';
import 'package:netlens/model/netlens_http_call.dart';
import 'package:netlens_test/netlens_test.dart';
import 'package:test/test.dart';

void main() {
  late NetLensCore netLensCore;

  setUp(() {
    registerFallbackValue(NetLensHttpCall(0));
    netLensCore = NetLensCoreMock();
    when(() => netLensCore.addCall(any())).thenAnswer((_) {});
  });

  test('adds the call to NetLens', () {
    // Make your adapter catch a GET request with netLensCore injected.

    verify(
      () => netLensCore.addCall(
        any(that: buildCallMatcher(checkTime: true, method: 'GET')),
      ),
    );
  });
}

The adapter tests in packages use these matchers, for example netlens_http.

0
likes
160
points
58
downloads

Documentation

API reference

Publisher

verified publishershewa.tech

Weekly Downloads

Test matchers and mocks for writing and testing adapters of the NetLens in-app HTTP inspector.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

mocktail, netlens, test

More

Packages that depend on netlens_test