pub struct Options {
pub computed_style_supports_pseudo_elements: Option<bool>,
pub default_hidden: Option<bool>,
pub default_ignore: Option<String>,
pub show_original_stack_trace: Option<bool>,
pub throw_suggestions: Option<bool>,
pub test_id_attribute: Option<String>,
pub async_util_timeout: Option<u64>,
}
Expand description
Configuration options for the testing library
Fields§
§computed_style_supports_pseudo_elements: Option<bool>
Set to true if window.getComputedStyle supports pseudo-elements i.e. a second argument. If you’re using testing-library in a browser you almost always want to set this to true. Only very old browser don’t support this property (such as IE 8 and earlier). However, jsdom does not support the second argument currently. This includes versions of jsdom prior to 16.4.0 and any version that logs a not implemented warning when calling getComputedStyle with a second argument e.g. window.getComputedStyle(document.createElement(‘div’), ‘::after’). Defaults to false
The default value for the hidden option used by getByRole. Defaults to false.
default_ignore: Option<String>
The default value for the ignore option used by getByText. Also determines the nodes that are being ignored when errors are printed. Defaults to “script, style”.
show_original_stack_trace: Option<bool>
By default, waitFor will ensure that the stack trace for errors thrown by Testing Library is cleaned up and shortened so it’s easier for you to identify the part of your code that resulted in the error (async stack traces are hard to debug). If you want to disable this, then set showOriginalStackTrace to false. You can also disable this for a specific call in the options you pass to waitFor.
throw_suggestions: Option<bool>
When enabled, if better queries are available, the test will fail and provide a suggested query to use instead. Defaults to false.
test_id_attribute: Option<String>
The attribute used by getByTestId and related queries. Defaults to “data-testid”.
async_util_timeout: Option<u64>
The global timeout value in milliseconds used by waitFor utilities. Defaults to 1000ms.
Implementations§
Source§impl Options
impl Options
Sourcepub fn with_computed_style_supports_pseudo_elements(self, value: bool) -> Self
pub fn with_computed_style_supports_pseudo_elements(self, value: bool) -> Self
Builder method to set computed_style_supports_pseudo_elements
Builder method to set default_hidden
Sourcepub fn with_default_ignore(self, value: &str) -> Self
pub fn with_default_ignore(self, value: &str) -> Self
Builder method to set default_ignore
Sourcepub fn with_show_original_stack_trace(self, value: bool) -> Self
pub fn with_show_original_stack_trace(self, value: bool) -> Self
Builder method to set show_original_stack_trace
Sourcepub fn with_throw_suggestions(self, value: bool) -> Self
pub fn with_throw_suggestions(self, value: bool) -> Self
Builder method to set throw_suggestions
Sourcepub fn with_test_id_attribute(self, value: &str) -> Self
pub fn with_test_id_attribute(self, value: &str) -> Self
Builder method to set test_id_attribute
Sourcepub fn with_async_util_timeout(self, value: u64) -> Self
pub fn with_async_util_timeout(self, value: u64) -> Self
Builder method to set async_util_timeout
Sourcepub fn to_json_string(&self) -> Result<String, Error>
pub fn to_json_string(&self) -> Result<String, Error>
Serialize the options to JSON string