-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
use vite and vitest #236
Conversation
72def6b
to
d079983
Compare
There was a problem hiding this 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
src/test/RequestQueue.test.ts
Outdated
test("can issue and cancel mock loadspec requests", async () => { | ||
const fn = vi.fn(); | ||
let count = 0; | ||
const unhandledpromise = new Promise<void>((resolve) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
const unhandledpromise = new Promise<void>((resolve) => { | |
const unhandledPromise = new Promise<void>((resolve) => { |
src/test/RequestQueue.test.ts
Outdated
@@ -489,6 +500,11 @@ describe("test RequestQueue", () => { | |||
expect(workCount) | |||
.to.be.lessThan(2 * numFrames) | |||
.and.greaterThanOrEqual(numFrames); | |||
|
|||
await unhandledpromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
initial work toward #147
use vite for demo app and vitest for unit tests
status:
npm start
will correctly fire up the test app