taichi.js icon indicating copy to clipboard operation
taichi.js copied to clipboard

Use `deno.ts` for running tests

Open AmesingFlank opened this issue 2 years ago • 1 comments

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.

AmesingFlank avatar Apr 22 '22 11:04 AmesingFlank

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

manzt avatar Sep 16 '22 17:09 manzt