Voltest runs frontend tests for Volt projects.
It compiles test modules with Volt, resolves imports through Volt plugins and aliases, executes the compiled test bundle, and reports results through Mix.
Add Voltest to a project that already uses Volt:
def deps do
[
{:volt, "~> 0.13"},
{:voltest, "~> 0.1", only: [:dev, :test], runtime: false}
]
endThen run frontend test files with:
mix voltestSpecific files or directories can be passed explicitly:
mix voltest assets/test/example.test.ts
mix voltest assets/test --grep "updates state"Test files can import from voltest:
import { describe, expect, test } from "voltest";
describe("math", () => {
test("adds numbers", () => {
expect(1 + 1).toBe(2);
});
});Voltest also resolves vitest imports to the same runtime API for projects that
already have Vitest-style frontend tests.
Voltest currently provides:
describe,test/it,skip,only, andeachbeforeAll,beforeEach,afterEach, andafterAll- common
expectmatchers vi.fn,vi.spyOn,vi.mocked, and mock reset / restore helpers- top-level
vi.mocksupport through a Volt transform - basic browser-like primitives including
Headers,Request,Response,location, events,localStorage, andsessionStorage