-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Port react-conformance tests to testing-library #22009
Changes from all commits
7f69874
37770e0
5b1d992
fdca6f6
3303560
052159c
2a20e6b
b860251
b5605a7
50cfdc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "BREAKING CHANGE: Switch from Enzyme to `@testing-library/react` and remove Enzyme-specific APIs", | ||
"packageName": "@fluentui/react-conformance", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Fix cleanup of overridesWin test", | ||
"packageName": "@fluentui/react-conformance-griffel", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { isConformant } from 'test/specs/commonTests'; | ||
import { FormButton } from 'src/components/Form/FormButton'; | ||
import { FormButton, formButtonClassName } from 'src/components/Form/FormButton'; | ||
import { Button } from 'src/components/Button/Button'; | ||
|
||
describe('FormButton', () => { | ||
|
@@ -8,5 +8,7 @@ describe('FormButton', () => { | |
constructorName: 'FormButton', | ||
forwardsRefTo: `Button`, | ||
targetComponent: Button, | ||
getTargetElement: (result, attr) => | ||
attr === 'className' ? result.container.querySelector(`.${formButtonClassName}`) : result.getByRole('button'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since react-conformance no longer uses enzyme's |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { isConformant } from 'test/specs/commonTests'; | ||
import { FormDatepicker } from 'src/components/Form/FormDatepicker'; | ||
import { Datepicker } from 'src/components/Datepicker/Datepicker'; | ||
import { FormDatepicker, formDatepickerClassName } from 'src/components/Form/FormDatepicker'; | ||
import { Datepicker, datepickerClassName } from 'src/components/Datepicker/Datepicker'; | ||
|
||
describe('FormDatepicker', () => { | ||
isConformant(FormDatepicker, { | ||
testPath: __filename, | ||
constructorName: 'FormDatepicker', | ||
forwardsRefTo: false, | ||
targetComponent: Datepicker, | ||
getTargetElement: (result, attr) => | ||
attr === 'className' | ||
? result.container.querySelector(`.${formDatepickerClassName}`) | ||
: result.container.querySelector(`.${datepickerClassName}`), | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { isConformant } from 'test/specs/commonTests'; | ||
import { FormDropdown } from 'src/components/Form/FormDropdown'; | ||
import { Dropdown } from 'src/components/Dropdown/Dropdown'; | ||
import { FormDropdown, formDropdownClassName } from 'src/components/Form/FormDropdown'; | ||
import { Dropdown, dropdownClassName } from 'src/components/Dropdown/Dropdown'; | ||
|
||
describe('FormDropdown', () => { | ||
isConformant(FormDropdown, { | ||
testPath: __filename, | ||
constructorName: 'FormDropdown', | ||
forwardsRefTo: false, | ||
targetComponent: Dropdown, | ||
getTargetElement: (result, attr) => | ||
attr === 'className' | ||
? result.container.querySelector(`.${formDropdownClassName}`) | ||
: result.container.querySelector(`.${dropdownClassName}`), | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,10 @@ export const overridesWin: ConformanceTest = (componentInfo, testInfo) => { | |
document.body.appendChild(container); | ||
}); | ||
|
||
afterEach(() => { | ||
afterEach(async () => { | ||
if (container) { | ||
const ReactDOM = await import('react-dom'); | ||
ReactDOM.unmountComponentAtNode(container); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After removing the "nuclear" |
||
document.body.removeChild(container); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"lib": ["DOM", "ES2019"], | ||
"outDir": "dist", | ||
"declaration": true, | ||
"types": ["static-assets", "environment", "jest"], | ||
"types": ["static-assets", "environment", "jest", "node"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add this to make the build pass after enzyme types and their indirect node type leakage were removed |
||
"module": "CommonJS" | ||
}, | ||
"exclude": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.test.ts", "**/*.test.tsx"], | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
const { createConfig } = require('@fluentui/scripts/jest/jest-resources'); | ||
const path = require('path'); | ||
|
||
const config = createConfig({ | ||
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))], | ||
}); | ||
const config = createConfig({}); | ||
|
||
module.exports = config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference https://testing-library.com/docs/react-testing-library/api#wrapper