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

test(project): update tests for React 18 #2673

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
493b945
test(ThemeProvider): update test to use userEvents
joshblack Dec 8, 2022
6bf3d27
test(helpers): add TextEncoder for useMedia
joshblack Dec 8, 2022
02d59c8
test(MarkdownEditor): update tests for MarkdownEditor
joshblack Dec 9, 2022
9f14cc5
test: update TextInputWithTokens test
joshblack Dec 9, 2022
e2b75b4
test(MarkdownEditor): enable skipped tests
joshblack Dec 9, 2022
1950d9d
chore: add spy for console.error() in test
joshblack Dec 12, 2022
4ef894e
chore: add globals for react version
joshblack Dec 12, 2022
14a5c65
chore: remove storybook-addon-html
joshblack Dec 9, 2022
06f24bb
chore: update storybook deps
joshblack Dec 9, 2022
a6c9109
chore: remove conditional install step from ci.yml
joshblack Dec 9, 2022
63c0efa
Revert "chore: remove conditional install step from ci.yml"
joshblack Dec 9, 2022
e32c00f
feat(project): update to React 18 for development
joshblack Dec 9, 2022
01a7b1f
ci: update install step to use 18 by default
joshblack Dec 9, 2022
2e3705f
chore: update lockfile
joshblack Dec 9, 2022
4be894f
chore: update eslint to warn on useSSRSafeId
joshblack Dec 9, 2022
9a07747
feat(project): add useId hook
joshblack Dec 9, 2022
fe2c4c8
feat(project): update useSSRSafeId to useId
joshblack Dec 9, 2022
2f185ad
chore: disable eslint violations
joshblack Dec 9, 2022
7074a78
test: map useId() to useSSRSafeId() in test
joshblack Dec 12, 2022
fdf2284
test(storybook): update interaction tests for UnderlineNav
joshblack Dec 13, 2022
e335265
chore: add changeset
joshblack Dec 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-peas-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Update to React.useId() when using React 18
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
{
"ts-ignore": "allow-with-description"
}
],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@react-aria/ssr",
"importNames": ["useSSRSafeId"],
"message": "Please use the `useId` hook from `src/hooks/useId.ts` instead"
}
],
"patterns": []
}
]
}
},
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ jobs:
run: node script/set-react-version.js ${{ matrix.react }}

- name: Install dependencies
if: ${{ matrix.react == 18 }}
if: ${{ matrix.react == 17 }}
run: npm install --legacy-peer-deps

- name: Install dependencies
if: ${{ matrix.react == 17 }}
if: ${{ matrix.react == 18 }}
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm run test -- --coverage
with:
REACT_VERSION_17: ${{ matrix.react == 17 }}

type-check:
strategy:
Expand All @@ -78,11 +80,11 @@ jobs:
run: node script/set-react-version.js ${{ matrix.react }}

- name: Install dependencies
if: ${{ matrix.react == 18 }}
if: ${{ matrix.react == 17 }}
run: npm install --legacy-peer-deps

- name: Install dependencies
if: ${{ matrix.react != 18 }}
if: ${{ matrix.react != 17 }}
run: npm ci

- name: Type check
Expand Down
19 changes: 8 additions & 11 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@ module.exports = {
{
name: 'storybook-addon-turbo-build',
options: {
optimizationLevel: 2
}
optimizationLevel: 2,
},
},
...(process.env.NODE_ENV === 'production' && process.env.GITHUB_JOB !== 'chromatic'
? ['@whitespace/storybook-addon-html']
: [])
],
core: {
builder: {
name: 'webpack5',
options: {
fsCache: true
}
}
fsCache: true,
},
},
},
features: {
interactionsDebugger: true,
storyStoreV7: true,
buildStoriesJson: true
buildStoriesJson: true,
},
framework: '@storybook/react',
reactOptions: {
fastRefresh: true,
strictMode: true
}
strictMode: true,
},
}
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
/* eslint-disable github/unescaped-html-literal */

'use strict'

const {REACT_VERSION_17} = process.env

/**
* @type {import('jest').Config}
*/
module.exports = {
globals: {
REACT_VERSION_LATEST: REACT_VERSION_17 ? REACT_VERSION_17 !== 'true' : true,
REACT_VERSION_17: REACT_VERSION_17 === 'true',
},
testEnvironment: 'jsdom',
cacheDirectory: '.test',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/stories/**', '!**/*.stories.{js,jsx,ts,tsx}'],
Expand Down
Loading