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

reinitialization w/ vite #69

Merged
merged 32 commits into from
Oct 16, 2024
Merged

reinitialization w/ vite #69

merged 32 commits into from
Oct 16, 2024

Conversation

mikellewade
Copy link
Contributor

@mikellewade mikellewade commented Jan 24, 2024

Asana Ticket: https://app.asana.com/0/1205655776549324/1205770483276175/f

PR to port React Chatlog from yarn/CRA to npm/VIte:

Testing

create-react-app is no longer being maintained and therefore removed react-scripts from project and replaced with vitest. vitest is maintained by the vite team and offers benefits such as speed and pipelining configurations. Though we won't necessarily see the benefits of this with the scope of React chatlog, instructors (Mikelle, Ansel, and Ashley) decided that vitest would be the best route to take when weighed against configuring Jest testing for the project (Jest does not intrinsically know anything about JSX files). To run the testing command in terminal run npm run test and for VScode please install: https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer

https://vitest.dev/guide/

Copy link
Contributor

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

The linter wasn't working for me out of the box. There are some lingering jest stuff that's gumming it up. I included the version of .eslintrc.js that I was able to get working, and the plugin that needs to be installed in the package.json. After that, a lint pass would be a good idea.

There are a few tickets for this project that we could include in this change as well (links in a comment)

The images should be updated for our new standards.

We should update the docker container and test it in learn to make sure that it works properly (see comment on test.sh).

Copy link
Contributor

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the other related tickets. I made a few phrasing suggestions. I'm also wondering whether we should leave some of those starting imports, even though they do cause linter errors at the start. Details in the comments.

import ChatEntry from './ChatEntry';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is vitest compatible with this jest-dom testing library? Why did it change from the previous import '@testing-library/jest-dom/extend-expect';?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had ran into the error Error: Missing "./extend-expect" specifier in "@testing-library/jest-dom" package and came across this as a solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. And that import is providing the toBeInTheDocument() method. And that neceissitated adding the vitest setup file to extend expect manually. Got it. Thanks. 👍

@@ -1,6 +1,4 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

The import React lines were causing linter warnings and are no longer necessary, so removing those is fine. 👍

For other imports in the project, even though they report linter warnings on the bare project, should we leave them in since they'll be needed later? Or maybe we should add reminders to the waves where they would be required for students to add them?

For the latter, I would say that we don't need to provide the explicit import line itself, but maybe something more along the lines of

Remember that the values we need for defining proptypes come from an external library and must be imported. We'll also need to be sure to import any other components used in each file.

Here especially, I'd be a little concerned that students wouldn't know to import the json file as we're doing, since we nevere really talk about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This crossed my as well, my initial thought was to leave them out since they would encounter errors in the console if they try to utilize them without importing. I figured it would be a good place for them to get that practice. I think your reminder is a good one! You want to add to every wave, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you prefer adding reminders to having the imports, that works for me too. In the required implementation, it looks like only waves 1 and 2 require adding imports. Wave 2 would need to also mention importing the json file (maybe say that the name used in the import will end up being the variable name we'll use to access the loaded data?) The optional enhancements might also require some imports depending on their implementation choices, so maybe a fairly broad statement about being sure to keep track of their imports as they work?

Copy link
Contributor

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

LGTM. Just needs a minor update to the links to the messages.json file.


Note: We do not need to include the `id` and `liked` fields for Wave 01. Additionally, you should not build your own logic to handle converting the absolute value of `timeStamp` to a relative value for display. Please refer to the [setup docs](./setup.md#hint-the-timestamp-component) for tips about how to utilize the `TimeStamp` component already provided.

## Imports
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


![Wave 02 One Sided Messages](../images/react-chatlog-demo-one-sided-messages.png)

## Imports
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

mikellewade and others added 2 commits October 16, 2024 13:06
@mikellewade mikellewade merged commit f2e2f22 into main Oct 16, 2024
@mikellewade mikellewade deleted the mikellewade/vite branch October 16, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants