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

Fix console.error being called in tests #1966

Merged
merged 6 commits into from
May 9, 2023
Merged

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented May 4, 2023

Tests were printing

  ● simple databinding

    Expected test not to call console.error().

    If the error is expected, test for it explicitly by mocking it out using jest.spyOn(console, 'error').mockImplementation() and test that the warning occurs.

    Warning: An update to Form inside a test was not wrapped in act(...).
    
    When testing, code that causes React state updates should be wrapped into act(...):
    
    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */
    
    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
  ...

But still passing

Noticed while working on #1965

I suspect this started happening since adding the Form component.

Related thread: https://github.com/orgs/react-hook-form/discussions/4232

@Janpot Janpot added the test label May 4, 2023
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 5, 2023
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels May 5, 2023
Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 7, 2023
import ToolpadApp from './ToolpadApp';
import * as appDom from '../appDom';
import createRuntimeState from '../createRuntimeState';
import { bridge } from '../canvas/ToolpadBridge';
import { BridgeContext } from '../canvas/BridgeContext';
import loadComponents from './loadDomComponents';

failOnConsole();
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to set this globally for any spec file?
This library seems to recommend using the file for setupFilesAfterEnv for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure 👍

@Janpot Janpot enabled auto-merge (squash) May 9, 2023 08:28
@Janpot Janpot merged commit 5584385 into mui:master May 9, 2023
@Janpot Janpot deleted the test-console-error branch May 9, 2023 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants