remove enzyme code studio and replace with react-testing-library#565
Conversation
Codecov Report
@@ Coverage Diff @@
## main #565 +/- ##
==========================================
+ Coverage 36.43% 36.68% +0.25%
==========================================
Files 390 390
Lines 28642 28655 +13
Branches 6777 6775 -2
==========================================
+ Hits 10436 10513 +77
+ Misses 17860 17796 -64
Partials 346 346
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…/web-client-ui into 562-remove-enzyme-code-studio
| // jest.mock('@deephaven/components', () => ({ | ||
| // ...jest.requireActual('@deephaven/components'), | ||
| // __esModule: true, | ||
| // Popper: jest.fn(({ children }) => { | ||
| // return children; | ||
| // }), | ||
| // default: jest.fn(), | ||
| // })); | ||
|
|
There was a problem hiding this comment.
Delete unused
| // jest.mock('@deephaven/components', () => ({ | |
| // ...jest.requireActual('@deephaven/components'), | |
| // __esModule: true, | |
| // Popper: jest.fn(({ children }) => { | |
| // return children; | |
| // }), | |
| // default: jest.fn(), | |
| // })); |
| jest.mock('@deephaven/dashboard', () => ({ | ||
| ...jest.requireActual('@deephaven/dashboard'), | ||
| __esModule: true, | ||
| Dashboard: jest.fn(({ hydrate }) => { | ||
| const result = hydrate(mockProp, mockId); | ||
| if (result.fetch) { | ||
| result.fetch(); | ||
| } | ||
| return <p>{JSON.stringify(result)}</p>; | ||
| }), | ||
| default: jest.fn(), | ||
| })); |
There was a problem hiding this comment.
The reason why you were still getting the mockConstructor error here is because you're only passing jest.fn() here for default. You could keep the default import and then just set default instead of Dashboard here, e.g.:
| jest.mock('@deephaven/dashboard', () => ({ | |
| ...jest.requireActual('@deephaven/dashboard'), | |
| __esModule: true, | |
| Dashboard: jest.fn(({ hydrate }) => { | |
| const result = hydrate(mockProp, mockId); | |
| if (result.fetch) { | |
| result.fetch(); | |
| } | |
| return <p>{JSON.stringify(result)}</p>; | |
| }), | |
| default: jest.fn(), | |
| })); | |
| jest.mock('@deephaven/dashboard', () => ({ | |
| ...jest.requireActual('@deephaven/dashboard'), | |
| __esModule: true, | |
| default: jest.fn(({ hydrate }) => { | |
| const result = hydrate(mockProp, mockId); | |
| if (result.fetch) { | |
| result.fetch(); | |
| } | |
| return <p>{JSON.stringify(result)}</p>; | |
| }), | |
| })); |
Change the import in AppMainContainer is also acceptable, but then you don't need to have the __esModule: true, default: jest.fn() bit here.
| plugins = new Map(), | ||
| } = {}) { | ||
| return shallow( | ||
| return ( |
There was a problem hiding this comment.
If you kept this method as renderAppMainContainer, and then do a return render(<AppMainContainer ... />) here, then you can just call renderAppMainContainer() in all the tests below without having to wrap it in render each time like render(getAppMainContainer()). Not a big deal either way.
| }) | ||
| ); | ||
| expect(result).not.toEqual(expect.objectContaining({ fetch: expect.any })); | ||
| session = makeSession(); |
There was a problem hiding this comment.
You could still keep the beforeEach block with the makeSession in it, as it makes it clear the session is always initialized to the same thing.
Fixes #562