Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Add reactotron to storybook #87

Merged
merged 3 commits into from
Sep 11, 2018
Merged

Conversation

derekgreenberg
Copy link
Member

@derekgreenberg derekgreenberg commented Sep 10, 2018

New Trello Board link: https://trello.com/c/YPZKngqg/28-configure-reactotron-in-storybook

Closes #81

Implements add-reactotron-to-storybook based on Kevin's suggestion in #81

Reactotron now executes when running storybook tests. It shuts off as expected when running yarn test.

This PR fixes this test warning:

"console.warn node_modules/react-native/jest/setup.js:91
Calling .blur() in the test renderer environment is not supported. Instead, mock out your components that use findNodeHandle with replacements that don't rely on the native environment."
by adding a new mock for text-input "mock-textinput.ts" that sets the "autoFocus" prop to false when tests are running.

Fixed a bunch of rendering issues with Storybook tests.

(1) The default color of the Text component is white, which is not visible in the storybook tests.
(2) missing en_US translations for the text-field.story.

What follows is screenshots for all fixed Storybook renderings:

formrowassembled

formrowpresets

headerbehavior

textfieldstyleoverrides

textfiieldlabelling

textpassingcontent

textstylepresets

"preset": "jest-preset-ignite"
"preset": "jest-preset-ignite",
"testPathIgnorePatterns": [
"/e2e/",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is only necessary if using Detox (Bowser does not) and the Detox tests are located in the e2e folder, which I'm not certain is the default, so I would probably suggest removing this line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, will remove.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinvangelder removed this line in package.json. Final verion

  "jest": {
    "preset": "jest-preset-ignite",
    "testPathIgnorePatterns": [
      "/node_modules"
    ],
    "globals": {
      "__TEST__": true
    }
  },

Copy link
Contributor

@skellock skellock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -12,6 +12,11 @@ const StorybookUI = getStorybookUI({ port: 9001, host: "localhost", onDeviceUI:
export class StorybookUIRoot extends React.Component {
componentDidMount() {
SplashScreen.hide()
if (typeof __TEST__ === "undefined" || !__TEST__) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined is falsy, so you could use !__TEST__.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would think that, but it was causing explosions, hence this solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. So leaving this as if (typeof __TEST__ === "undefined" || !__TEST__)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fair, it was exploding prior to declaring TEST in setup.ts, but I'm pretty sure I tested removing this after that and still faced issues.

@derekgreenberg derekgreenberg merged commit 3a02d7d into master Sep 11, 2018
@derekgreenberg derekgreenberg deleted the add-reactotron-to-storybook branch September 11, 2018 17:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants