Skip to content

Commit a162e5b

Browse files
authored
Commands to run tests and storybook in StrictMode (#3241)
* strict mode work in progress * move import from testing-library to test-utils IMO better to have a single place to import all of out test utils, makes it easier to keep track * making storybook handle strict mode via options * revert change to storybook config
1 parent 9078b1d commit a162e5b

File tree

130 files changed

+180
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+180
-228
lines changed

.storybook/custom-addons/provider/index.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React, {useEffect, useState} from 'react';
2-
import {ActionButton} from '@react-spectrum/button';
32
import addons, { makeDecorator } from '@storybook/addons';
4-
import {Content} from '@react-spectrum/view';
53
import {getQueryParams} from '@storybook/client-api';
64
import {Provider} from '@react-spectrum/provider';
7-
import {Text} from '@react-spectrum/text';
85
import {themes, defaultTheme} from '../../constants';
9-
import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
106

117
document.body.style.margin = '0';
128

@@ -48,29 +44,13 @@ function ProviderUpdater(props) {
4844
return (
4945
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue} toastPlacement={toastPositionValue}>
5046
<main>
51-
<div style={{position: 'absolute', paddingTop: '20px', paddingLeft: '20px', paddingRight: '20px'}}>
52-
{props.context.parameters.note && (<DialogTrigger type="popover">
53-
<ActionButton>Note</ActionButton>
54-
<Dialog>
55-
<Content><Text>{props.context.parameters.note}</Text></Content>
56-
</Dialog>
57-
</DialogTrigger>)}
58-
</div>
5947
{storyReady && props.children}
6048
</main>
6149
</Provider>
6250
);
6351
} else {
6452
return (
6553
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue} toastPlacement={toastPositionValue}>
66-
<div style={{position: 'absolute', paddingTop: '20px', paddingLeft: '20px', paddingRight: '20px'}}>
67-
{props.context.parameters.note && (<DialogTrigger type="popover">
68-
<ActionButton>Note</ActionButton>
69-
<Dialog>
70-
<Content><Text>{props.context.parameters.note}</Text></Content>
71-
</Dialog>
72-
</DialogTrigger>)}
73-
</div>
7454
{storyReady && props.children}
7555
</Provider>
7656
);

.storybook/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ module.exports = {
3636
}
3737

3838
return resultConfig;
39-
}
39+
},
40+
reactOptions: {
41+
strictMode: process.env.STRICT_MODE
42+
},
4043
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"install-16": "yarn add -W react@^16.8.0 react-dom@^16.8.0 @testing-library/react@^12 @testing-library/react-hooks@^8",
1313
"install-17": "yarn add -W react@^17 react-dom@^17 @testing-library/react@^12 @testing-library/react-hooks@^8",
1414
"start": "cross-env NODE_ENV=storybook start-storybook -p 9003 --ci -c '.storybook'",
15+
"start-strict": "cross-env NODE_ENV=storybook STRICT_MODE=1 start-storybook -p 9003 --ci -c '.storybook'",
1516
"build:storybook": "build-storybook -c .storybook -o dist/$(git rev-parse HEAD)/storybook",
1617
"build:storybook-16": "build-storybook -c .storybook -o dist/$(git rev-parse HEAD)/storybook-16",
1718
"build:storybook-17": "build-storybook -c .storybook -o dist/$(git rev-parse HEAD)/storybook-17",
@@ -20,6 +21,7 @@
2021
"start:docs": "DOCS_ENV=dev parcel 'packages/@react-{spectrum,aria,stately}/*/docs/*.mdx' 'packages/@internationalized/*/docs/*.mdx' 'packages/dev/docs/pages/**/*.mdx'",
2122
"build:docs": "DOCS_ENV=staging parcel build 'packages/@react-{spectrum,aria,stately}/*/docs/*.mdx' 'packages/@internationalized/*/docs/*.mdx' 'packages/dev/docs/pages/**/*.mdx'",
2223
"test": "yarn jest",
24+
"test-strict": "cross-env STRICT_MODE=1 yarn jest",
2325
"build": "make build",
2426
"test:ssr": "yarn jest --config jest.ssr.config.js",
2527
"ci-test": "yarn jest --maxWorkers=2 && yarn test:ssr --runInBand",

packages/@adobe/react-spectrum/test/ActionGroup.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {ActionGroup, Item} from '../';
1414
import {Provider} from '@react-spectrum/provider';
1515
import React from 'react';
16-
import {render} from '@testing-library/react';
16+
import {render} from '@react-spectrum/test-utils';
1717
import scaleMedium from '@adobe/spectrum-css-temp/vars/spectrum-medium-unique.css';
1818
import themeLight from '@adobe/spectrum-css-temp/vars/spectrum-light-unique.css';
1919

packages/@react-aria/aria-modal-polyfill/test/index.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, fireEvent, render, waitFor} from '@testing-library/react';
13+
import {act, fireEvent, render, triggerPress, waitFor} from '@react-spectrum/test-utils';
1414
import {ActionButton, Button} from '@react-spectrum/button';
1515
import {Content} from '@react-spectrum/view';
1616
import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
@@ -19,7 +19,6 @@ import MatchMediaMock from 'jest-matchmedia-mock';
1919
import {Provider} from '@react-spectrum/provider';
2020
import React from 'react';
2121
import {theme} from '@react-spectrum/theme-default';
22-
import {triggerPress} from '@react-spectrum/test-utils';
2322
import {watchModals} from '../';
2423

2524
describe('watchModals', () => {

packages/@react-aria/calendar/test/useCalendar.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, fireEvent, render} from '@testing-library/react';
13+
import {act, fireEvent, render} from '@react-spectrum/test-utils';
1414
import {CalendarDate} from '@internationalized/date';
1515
import {Example} from '../stories/Example';
1616
import React from 'react';

packages/@react-aria/checkbox/test/useCheckboxGroup.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, render} from '@testing-library/react';
13+
import {act, render} from '@react-spectrum/test-utils';
1414
import {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps} from '@react-types/checkbox';
1515
import {CheckboxGroupState, useCheckboxGroupState} from '@react-stately/checkbox';
1616
import React, {useRef} from 'react';

packages/@react-aria/color/test/useColorWheel.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, fireEvent, render} from '@testing-library/react';
13+
import {act, fireEvent, installMouseEvent, installPointerEvent, render} from '@react-spectrum/test-utils';
1414
import {ColorWheelProps} from '@react-types/color';
15-
import {installMouseEvent, installPointerEvent} from '@react-spectrum/test-utils';
1615
import {parseColor, useColorWheelState} from '@react-stately/color';
1716
import React, {useRef} from 'react';
1817
import {useColorWheel} from '../';

packages/@react-aria/dialog/test/useDialog.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import React, {useRef} from 'react';
14-
import {render} from '@testing-library/react';
14+
import {render} from '@react-spectrum/test-utils';
1515
import {useDialog} from '../';
1616

1717
function Example(props) {

packages/@react-aria/dnd/test/dnd.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
jest.mock('@react-aria/live-announcer');
14-
import {act, fireEvent, render} from '@testing-library/react';
14+
import {act, fireEvent, render} from '@react-spectrum/test-utils';
1515
import {announce} from '@react-aria/live-announcer';
1616
import {CUSTOM_DRAG_TYPE} from '../src/constants';
1717
import {DataTransfer, DataTransferItem, DragEvent, FileSystemDirectoryEntry, FileSystemFileEntry} from './mocks';

0 commit comments

Comments
 (0)