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: migrate Editor tests to RTL #1624

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

erikian
Copy link
Member

@erikian erikian commented Aug 3, 2024

Ref: #1408.

@erikian erikian requested review from codebytere and a team as code owners August 3, 2024 20:12
@coveralls
Copy link

coveralls commented Aug 3, 2024

Coverage Status

coverage: 87.602%. remained the same
when pulling 6b06cdf on test/rtl-editor-component
into 3228c9c on main.

Comment on lines 32 to 39
it('renders the editor container', () => {
const { wrapper } = createEditor(MAIN_JS);
expect(wrapper.html()).toBe('<div class="editorContainer"></div>');
const id = MAIN_JS;
initializeEditorMosaic(id);

const { renderResult } = createEditor(id);

expect(renderResult.getByTestId('editorContainer')).toBeInTheDocument();
});
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this test is serving much purpose since it's checking for an empty div. Personally I'd rather drop it and avoid the need for testid here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that we're removing snapshot-based testing, I think these renders the component tests could at least act as basic smoke tests — for instance, if we change a component to render conditionally and it suddenly doesn't render anything with the props we're providing in the test, or if the component now crashes before rendering given the same props, the renders the component test will fail and we'll know right away that there's something wrong when mounting the component; that wouldn't be immediately obvious for a failure caused by bad props / bad prop validation in, say, the correctly sets the language test.

I don't feel strongly about this though, so I'm happy to remove this test if we think it's fine to have other tests fail in case the component fails to render — I was mostly trying to keep the tests we already had in some way.

Copy link
Member

Choose a reason for hiding this comment

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

Now that we're removing snapshot-based testing, I think these renders the component tests could at least act as basic smoke tests

I agree. This one is just an extreme case where it's just an empty div. I'd like to avoid needing to add data-testid, but I'm fine with keeping it in this case, I don't feel strongly on this either.

@dsanders11 dsanders11 merged commit 88e1209 into main Aug 20, 2024
9 checks passed
@dsanders11 dsanders11 deleted the test/rtl-editor-component branch August 20, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants