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

use vite and vitest #236

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

use vite and vitest #236

wants to merge 13 commits into from

Conversation

toloudis
Copy link
Contributor

@toloudis toloudis commented Aug 17, 2024

initial work toward #147
use vite for demo app and vitest for unit tests

status:

  • npm start will correctly fire up the test app
  • tests (vitest), lint, typeCheck work
  • TODO/future: vite can not be used to build a library into the es/ directory yet (arguably there's no reason to, when we could use tsc etc)
  • TODO: gh-actions build of test app is probably broken, needs some way to verify that it works. maybe can save this for a followup PR.

@toloudis toloudis force-pushed the feature/vite-transpile branch from 72def6b to d079983 Compare December 29, 2024 03:41
@toloudis toloudis changed the title Feature/vite transpile use vite and vitest Dec 30, 2024
@toloudis toloudis marked this pull request as ready for review December 30, 2024 01:43
@toloudis toloudis requested a review from a team as a code owner December 30, 2024 01:43
@ShrimpCryptid ShrimpCryptid removed the request for review from a team January 6, 2025 17:40
Copy link
Contributor

@ShrimpCryptid ShrimpCryptid left a comment

Choose a reason for hiding this comment

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

LGTM! Left some minor comments

test("can issue and cancel mock loadspec requests", async () => {
const fn = vi.fn();
let count = 0;
const unhandledpromise = new Promise<void>((resolve) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
const unhandledpromise = new Promise<void>((resolve) => {
const unhandledPromise = new Promise<void>((resolve) => {

@@ -489,6 +500,11 @@ describe("test RequestQueue", () => {
expect(workCount)
.to.be.lessThan(2 * numFrames)
.and.greaterThanOrEqual(numFrames);

await unhandledpromise;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await unhandledpromise;
await unhandledPromise;

await unhandledpromise;
// This seems to be randomized. Expect some number of times either numFrames or numFrames-1.
expect([numFrames, numFrames - 1]).to.include(count);
//expect(fn).toHaveBeenCalledTimes(numFrames).or.toHaveBeenCalledTimes(numFrames - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

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 left it in because I was frustrated, to show that there's no syntactically clean/readable way to do this, but i'll remove it. it's just hard to read the "include" version on the line above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. Gotcha 👍

@@ -29,20 +27,20 @@ function isRejected(promise: Promise<unknown>): Promise<boolean> {

describe("SubscribableRequestQueue", () => {
describe("addSubscriber", () => {
it("adds a subscriber", () => {
test("adds a subscriber", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised you had to change all of the it declarations to test? I believe you can import it from vitest... but maybe this is nice so your tests aren't explicitly dependent on vitest.

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 was surprised that it gave me some kind of error and maybe I was too heavyhanded but the search and replace was easy and made things work. easy enough to change it back and try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

re-replaced! things are working and the diff is smaller

@ShrimpCryptid ShrimpCryptid linked an issue Jan 7, 2025 that may be closed by this pull request
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.

try vite
2 participants