Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate @storybook/addon-jest to TS #6403

Merged
merged 13 commits into from
Apr 8, 2019

Conversation

sairus2k
Copy link
Member

@sairus2k sairus2k commented Apr 3, 2019

Issue: #5030

What I did

  • Migrate @storybook/addon-jest to TypeScript
  • Rewrite createSubgroup function to more types-friendly
  • Extract Message component into separate file

@vercel
Copy link

vercel bot commented Apr 3, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://monorepo-git-fork-sairus2k-ts-migration-addon-jest.storybook.now.sh

@sairus2k sairus2k changed the title Ts migration/addon jest Migrate @storybook/addon-jest to TS Apr 3, 2019
@codecov
Copy link

codecov bot commented Apr 4, 2019

Codecov Report

Merging #6403 into next will increase coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #6403      +/-   ##
==========================================
+ Coverage   41.04%   41.11%   +0.06%     
==========================================
  Files         613      611       -2     
  Lines        8454     8440      -14     
  Branches      378      410      +32     
==========================================
  Hits         3470     3470              
+ Misses       4929     4915      -14     
  Partials       55       55
Impacted Files Coverage Δ
addons/jest/src/shared.ts 0% <ø> (ø)
addons/jest/src/components/Panel.tsx 0% <0%> (ø)
addons/jest/src/components/Result.tsx 0% <0%> (ø)
addons/jest/src/components/Message.tsx 0% <0%> (ø)
addons/jest/src/hoc/provideJestResult.tsx 0% <0%> (ø)
addons/jest/src/register.tsx 0% <0%> (ø)
addons/jest/src/components/Indicator.ts 0% <0%> (ø)
addons/jest/src/index.ts 0% <0%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1ffaac...f8db8e5. Read the comment docs.

addons/jest/package.json Outdated Show resolved Hide resolved
import PropTypes from 'prop-types';
import React from 'react';
import { styled } from '@storybook/theming';
import colors from '../colors';
Copy link
Member

Choose a reason for hiding this comment

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

I think these colours should come from the theme if possible

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I don't find similar colors in lib/theming/src/base.ts

addons/jest/src/register.tsx Outdated Show resolved Hide resolved
@ndelangen
Copy link
Member

addons/jest/src/styles.js → addons/jest/src/styles.ts

I'm unsure if this is still used, I can't find anything tht would use this.

I think we should delete this, or at the very least add a deprecation so we can remove it in a next release

@ndelangen
Copy link
Member

This is great! thanks for taking this on @sairus2k !

I think it works well and is merge-able.

We could do a bit more cleanup of this addon, how do you feel about doing that in this PR?

@ndelangen
Copy link
Member

Looks like you also need to remove addons/jest/styles.js

/tmp/storybook/addons/jest/styles.js
  1:9  error  Unable to resolve path to module './dist/styles'  import/no-unresolved

# Conflicts:
#	addons/jest/src/styles.js
{msg
.filter(item => typeof item !== 'string' || item.trim() !== '')
.map((item, index, list) => {
if (typeof item === 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems odd you filter for anything that isn't a string, then do something for only strings. seems like this code could be clearer

Copy link
Member Author

Choose a reason for hiding this comment

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

It filters for not empty strings, then removes line breaks for those strings

.map((i, index) => (index % 2 ? <Negative key={`n_${li}_${i}`}>{i}</Negative> : i))
: item
)
.reduce<MsgElement[]>((acc, item) => acc.concat(item), [])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.reduce<MsgElement[]>((acc, item) => acc.concat(item), [])
.reduce((acc, item) => acc.concat(item), [] as MsgElement[])

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case TS throws error Property 'concat' does not exist on type Element

@ndelangen ndelangen merged commit a315299 into storybookjs:next Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: jest maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants