taichi.js
taichi.js copied to clipboard
Use `deno.ts` for running tests
taichi.js heavily depends on WebGPU, which makes running tests very difficult.
Currently, the only way to run test is via the browser. More specifically, you need to do
npm run build_dev
npm run start
and then visit 127.0.0.1:8080/tests
Very recently, deno.ts has introduced WebGPU support, so it would be great if we could use that to run tests locally via a npm run tests
command.
Stumbled on this very cool project today. Another option could be @web/test-runner
. I tinkered around with it today but ran into some issues with type-only imports and ESM. Each test needs to be converted into it's own independent entry-point, e.g.,
// src/tests/TestFloat.ts
import * as ti from "../taichi"
import {assertEqual} from "./Utils"
// test is mocha global
test("testFloat", () => {
// test
});
// web-test-runner.config.mjs
import { esbuildPlugin } from "@web/dev-server-esbuild";
import { fromRollup } from "@web/dev-server-rollup";
import taichi from "./rollup/rollup-plugin-taichi/src/index.mjs"; // converted to ESM, with JSDoc annotations
/** @type {import('@web/test-runner').TestRunnerConfig} */
export default {
files: "./src/tests/Test*.ts",
nodeResolve: { browser: true },
plugins: [
esbuildPlugin({ ts: true, target: "auto" }),
fromRollup(taichi),
],
};
wtr # runs tests in browser