-
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
Changes from all commits
d079983
5302004
5c3ed8d
3a14287
f3a0606
7206709
ef1d33c
caba6c0
12e4213
1fa0de0
d7c68e9
fc08bb1
9e580b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,7 @@ lib | |
es | ||
build | ||
demo | ||
public/dist | ||
public/demo | ||
public/volumeviewer | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { expect } from "chai"; | ||
import { vi } from "vitest"; | ||
|
||
import { Vector3 } from "three"; | ||
import { TypedArray } from "@zarrita/core"; | ||
|
||
|
@@ -439,6 +440,16 @@ describe("test RequestQueue", () => { | |
} | ||
|
||
it("can issue and cancel mock loadspec requests", async () => { | ||
const fn = vi.fn(); | ||
let count = 0; | ||
const unhandledPromise = new Promise<void>((resolve) => { | ||
process.on("unhandledRejection", () => { | ||
fn(); | ||
count++; | ||
resolve(); | ||
}); | ||
}); | ||
|
||
const rq = new RequestQueue(10); | ||
const xDim = 400; | ||
const yDim = 600; | ||
|
@@ -489,6 +500,11 @@ describe("test RequestQueue", () => { | |
expect(workCount) | ||
.to.be.lessThan(2 * numFrames) | ||
.and.greaterThanOrEqual(numFrames); | ||
|
||
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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. Gotcha 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you could maybe use Whatever the case, it looks like |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { expect } from "chai"; | ||
import VolumeCache from "../VolumeCache"; | ||
|
||
describe("VolumeCache", () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"include": ["src/**/*"], | ||
"exclude": [ | ||
"src/workers/**/*", | ||
"**/*.test.js", | ||
"**/*.test.ts", | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { UserConfig } from "vite"; | ||
|
||
export default { | ||
plugins: [], | ||
define: { | ||
"APP_VERSION": JSON.stringify(process.env.npm_package_version), | ||
}, | ||
server: { | ||
open: "public/index.html", | ||
}, | ||
worker: { | ||
format: "es", | ||
}, | ||
} satisfies UserConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
environment: "jsdom", | ||
globals: true, | ||
setupFiles: [], | ||
}, | ||
}); |
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.