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

[core] Add strict option to createMount #15317

Merged
merged 11 commits into from
Apr 15, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Apr 11, 2019

Adds an option to createMount that allows mount tests to run in strict mode.

const strictMount = createMount({ strict: true });
strictMount(<div />); // <React.StrictMode><div /></React.StrictMode>

const looseMount = createMount({ strict: false });
looseMount(<div />); // <React.Fragment><div /></React.Fragment>

const mount = createMount();
mount(<div />); // <div />

Why is strict: false different than strict: undefined?

If you still rely on childAt(0), dive etc. consistently adding an additional level to the component tree allows toggling strict mode without changing your test assertions.

own test suite changes

Runs every test that uses createMount either in strict mode or not.

Implementation

https://github.com/mui-org/material-ui/pull/15317/files#diff-b24ed23497b02191114acc4c33e82796

@eps1lon eps1lon added the test label Apr 11, 2019
@eps1lon eps1lon added this to the 16.8 React.StrictMode milestone Apr 11, 2019
@eps1lon eps1lon changed the title Test/strict mode [test] Run in strict mode if possible Apr 11, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Apr 11, 2019

No bundle size changes comparing 1e86a1c...be2e430

Generated by 🚫 dangerJS against be2e430

@@ -39,7 +39,7 @@ describe('makeStyles', () => {
let generateClassName;

before(() => {
mount = createMount();
mount = createMount({ strict: undefined });
Copy link
Member Author

Choose a reason for hiding this comment

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

There were some very confusing fails. It's probably not strict mode ready at all.

@eps1lon eps1lon force-pushed the test/strict-mode branch 3 times, most recently from 16a6e0b to 8b51343 Compare April 12, 2019 09:58
@eps1lon eps1lon marked this pull request as ready for review April 12, 2019 13:06
@eps1lon eps1lon changed the title [test] Run in strict mode if possible [core] Add strict option to createMount Apr 13, 2019
@eps1lon eps1lon added new feature New feature or request package: material-ui Specific to @mui/material labels Apr 13, 2019
@oliviertassinari oliviertassinari merged commit 701a61d into mui:next Apr 15, 2019
@eps1lon eps1lon deleted the test/strict-mode branch April 15, 2019 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request package: material-ui Specific to @mui/material test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants