Skip to content

Commit e04c4e9

Browse files
authored
chore: Fix broken toast unit test and linting issue with inline stories (#978)
1 parent 8e53512 commit e04c4e9

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

.storybook/webpack.config.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
// When you add this file, we won't add the default configurations which is similar
77
// to "React Create App". This only has babel loader to load JavaScript.
88

9+
// Babel configuration for transpiling modern JS features in node_modules
10+
const babelConfigForNodeModules = {
11+
presets: [['@babel/preset-env', { targets: { browsers: 'defaults, not IE 11' } }]],
12+
plugins: [
13+
'@babel/plugin-proposal-class-properties',
14+
'@babel/plugin-proposal-optional-chaining',
15+
'@babel/plugin-proposal-nullish-coalescing-operator',
16+
],
17+
}
18+
919
module.exports = {
1020
plugins: [],
1121
module: {
@@ -28,10 +38,16 @@ module.exports = {
2838
loader: 'svg-url-loader',
2939
},
3040
{
31-
test: /\.(jsx?|tsx?)$/,
32-
// Exclude all node_modules from transpilation, except for Ariakit dependencies
33-
exclude: /node_modules\/(?!(ariakit.*)\/).*/,
34-
use: [{ loader: 'babel-loader' }],
41+
test: /\.(m?jsx?|tsx?)$/,
42+
// Exclude all node_modules from transpilation, except for Ariakit and Storybook testing libraries
43+
exclude: /node_modules\/(?!(ariakit.*|@storybook\/expect|@storybook\/jest|@adobe\/css-tools|@testing-library\/jest-dom)\/).*/,
44+
use: [{ loader: 'babel-loader', options: babelConfigForNodeModules }],
45+
},
46+
{
47+
test: /\.mjs$/,
48+
include: /node_modules/,
49+
type: 'javascript/auto',
50+
use: [{ loader: 'babel-loader', options: babelConfigForNodeModules }],
3551
},
3652
],
3753
},

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"poststart:yalc": "yalc installations clean",
5050
"start:yalc:success": "./scripts/organize-styles.sh && yalc push --sig",
5151
"build": "scripts/build.sh",
52-
"build:storybook": "NODE_OPTIONS=--openssl-legacy-provider build-storybook -o docs",
52+
"build:storybook": "build-storybook -o docs",
5353
"clean": "rimraf es lib styles dist",
5454
"test": "jest --passWithNoTests",
5555
"test:watch": "npm run test -- --watch",
@@ -71,7 +71,9 @@
7171
"@babel/plugin-proposal-class-properties": "^7.10.1",
7272
"@babel/plugin-proposal-export-default-from": "^7.0.0",
7373
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
74+
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
7475
"@babel/plugin-proposal-object-rest-spread": "^7.10.1",
76+
"@babel/plugin-proposal-optional-chaining": "7.21.0",
7577
"@babel/plugin-transform-spread": "^7.0.0",
7678
"@babel/polyfill": "^7.0.0",
7779
"@babel/preset-env": "^7.0.0",

src/inline/inline.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@ ResponsiveStory.argTypes = {
8888
export function NestedStackStory({ space }: PartialProps<typeof Inline>) {
8989
const spaceStr = typeof space !== 'string' ? 'none' : space
9090
return (
91-
<>
92-
<Stack space={space}>
93-
<Heading level="1">Parent stack with space=&ldquo;{spaceStr}&rdquo;</Heading>
94-
<Inline space="xsmall">{renderInlineContent()}</Inline>
95-
<Inline space="xsmall">{renderInlineContent()}</Inline>
96-
</Stack>
97-
</>
91+
<Stack space={space}>
92+
<Heading level="1">Parent stack with space=&ldquo;{spaceStr}&rdquo;</Heading>
93+
<Inline space="xsmall">{renderInlineContent()}</Inline>
94+
<Inline space="xsmall">{renderInlineContent()}</Inline>
95+
</Stack>
9896
)
9997
}
10098

src/toast/toast.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ describe('Toast', () => {
370370
)
371371
expect(screen.queryByRole('alert')).not.toBeInTheDocument()
372372
userEvent.click(screen.getByRole('button', { name: 'Toggle' }))
373-
expect(screen.getByRole('alert')).toHaveTextContent('A toast that can be toggled')
373+
await waitFor(() => {
374+
expect(screen.getByRole('alert')).toHaveTextContent('A toast that can be toggled')
375+
})
374376
userEvent.click(screen.getByRole('button', { name: 'Toggle' }))
375377
await waitFor(() => {
376378
expect(screen.queryByRole('alert')).not.toBeInTheDocument()

0 commit comments

Comments
 (0)