init static method

void init({
  1. bool autoReset = true,
  2. bool disableGoogleFonts = true,
})

Initialize the Nylo testing framework.

This should be called once at the beginning of your test file. It sets up:

  • Test mode flag
  • Flutter test bindings
  • Auto-mocked platform channels
  • In-memory cache
  • Google Fonts configuration (disables HTTP requests)

Example:

void main() {
  NyTest.init();

  nySetUpAll(() async {
    NyEnvRegistry.register(getter: Env.get);
    await setupApplication(providers);
  });

  nyWidgetTest('my test', (tester) async {
    await tester.pumpNyWidget(MyPage());
    expect(find.text('Hello'), findsOneWidget);
  });
}

Implementation

static void init({bool autoReset = true, bool disableGoogleFonts = true}) {
  TestWidgetsFlutterBinding.ensureInitialized();
  Nylo.isTestMode = true;
  NyMockChannels.setup();

  // Configure widget testing (disables Google Fonts HTTP requests)
  if (disableGoogleFonts) {
    NyWidgetTest.configure();
  }

  _initialized = true;

  if (autoReset) {
    setUp(() {
      // Fresh state for each test
    });

    tearDown(() {
      reset();
    });
  }
}