airbnb / airbnb/react-with-styles-interface-aphrodite

please export StyleSheetTestUtils

Open
#72 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
55
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Hi!
First of all thanks for making this interface!

Is it possible to export the following test-utility function from aphrodite:
StyleSheetTestUtils

This would remove the need to add the complete aphrodite dependency to a project while only actually using `react-with-styles-interface-aphrodite`, just for testing purposes.

I'm currently only using this interface for the react-dates dateRangePicker component but the tests are currently throwing this error:
```typescript
styleTag = document.querySelector("style[data-aphrodite]")
^
TypeError: Cannot read property 'querySelector' of null
```

This issue can be solved by adding the following for each test:
```typescript
beforeEach(() => {
StyleSheetTestUtils.suppressStyleInjection();
});
afterEach(() => {
StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
});
```

Since the `StyleSheetTestUtils` are not exported by `react-with-styles-interface-aphrodite` I'll need to install the complete aphrodite package just for testing, which feels like an overkill.

I'll prepare an PR for this.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the react-with-styles-interface-aphrodite package entry point and inspect how StyleSheetTestUtils is currently imported or exposed. Verify the export by using the suppressStyleInjection and clearBufferAndResumeStyleInjection calls in the react-dates dateRangePicker tests, and confirm the null style query error is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.