configure function Null safety

void configure(
  1. {String? testIdAttribute,
  2. int? asyncUtilTimeout,
  3. bool? computedStyleSupportsPseudoElements,
  4. bool? defaultHidden,
  5. bool? showOriginalStackTrace,
  6. bool? throwSuggestions,
  7. TestingLibraryElementError getElementError(
    1. Object? message,
    2. Element container
    )?}
)

Configuration for the react-testing-library.

See: testing-library.com/docs/dom-testing-library/api-configuration/

Implementation

void configure({
  String? testIdAttribute,
  int? asyncUtilTimeout,
  bool? computedStyleSupportsPseudoElements,
  bool? defaultHidden,
  bool? showOriginalStackTrace,
  bool? throwSuggestions,
  TestingLibraryElementError Function(Object? message, Element container)? getElementError,
}) {
  JsError _getJsGetElementError(Object? message, Element container) {
    final dartError = allowInterop(getElementError!)(message ?? '', container);
    return buildJsGetElementError(dartError.message, container);
  }

  final existingConfig = getConfig();
  return jsConfigure(JsConfig()
    ..testIdAttribute = testIdAttribute ?? existingConfig.testIdAttribute
    ..asyncUtilTimeout = asyncUtilTimeout ?? existingConfig.asyncUtilTimeout
    ..computedStyleSupportsPseudoElements =
        computedStyleSupportsPseudoElements ?? existingConfig.computedStyleSupportsPseudoElements
    ..defaultHidden = defaultHidden ?? existingConfig.defaultHidden
    ..showOriginalStackTrace = showOriginalStackTrace ?? existingConfig.showOriginalStackTrace
    ..throwSuggestions = throwSuggestions ?? existingConfig.throwSuggestions
    ..getElementError = getElementError != null ? allowInterop(_getJsGetElementError) : existingConfig.getElementError);
}