Skip to content

Commit

Permalink
Vitest (#1692)
Browse files Browse the repository at this point in the history
* Set up Vitest

* Run yarn dedupe

* Extract API

* Remove unused dependencies

* Remove script no longer needed

* Update yarn.lock

* Add vitest workspace and fix lib type checking

* Add vitest typings workaround

* Add noEmit to all test/tsconfig.js files

* Extract API

* Add back Assertions type

* Remove unused devDependencies found by knip

* Add back original alfa-test as alfa-test-deprecated

* Delete parts from old alfa-test that are no longer needed

* Update yarn.lock

* Add vitest as dependency to alfa-test and update valid external dependencies

* Add new API report

* Add changeset

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
rcj-siteimprove and github-actions[bot] authored Nov 28, 2024
1 parent d2515d9 commit de60ce9
Show file tree
Hide file tree
Showing 88 changed files with 1,908 additions and 432 deletions.
8 changes: 8 additions & 0 deletions .changeset/orange-points-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@siteimprove/alfa-test-deprecated": minor
"@siteimprove/alfa-test": minor
---

**Breaking:** The `alfa-test` package is now called `alfa-test-deprecated` and a new `alfa-test` package was added.

Consumers can either migrate by replacing references to `alfa-test` with `alfa-test-deprecated` or they can attempt to use `alfa-test` which builds on [Vitest](https://vitest.dev).
3 changes: 2 additions & 1 deletion config/validate-structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"noExternalDeps": true,
"allowedExternalDeps": {
"@siteimprove/alfa-compatibility": ["browserslist"],
"@siteimprove/alfa-test": ["chalk"],
"@siteimprove/alfa-test": ["vitest"],
"@siteimprove/alfa-test-deprecated": ["chalk"],
"@siteimprove/alfa-toolchain": [
"@changesets/assemble-release-plan",
"@changesets/config",
Expand Down
7 changes: 7 additions & 0 deletions config/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["test/**/*.spec.ts?(x)"],
},
});
1 change: 1 addition & 0 deletions config/vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ["packages/alfa-*", "!packages/alfa-test-deprecated"];
42 changes: 21 additions & 21 deletions docs/review/api/alfa-dom.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export namespace Attribute {
// (undocumented)
export interface MinimalJSON extends Node.JSON<"attribute"> {
}
const // Warning: (ae-forgotten-export) The symbol "predicate" needs to be exported by the entry point index.d.ts
const // Warning: (ae-forgotten-export) The symbol "predicate_3" needs to be exported by the entry point index.d.ts
//
// (undocumented)
hasName: typeof predicate.hasName;
hasName: typeof predicate_3.hasName;
}

// @public (undocumented)
Expand Down Expand Up @@ -374,28 +374,28 @@ export namespace Element {
// (undocumented)
style: Block.JSON | string | null;
}
const // Warning: (ae-forgotten-export) The symbol "predicate_3" needs to be exported by the entry point index.d.ts
const // Warning: (ae-forgotten-export) The symbol "predicate" needs to be exported by the entry point index.d.ts
//
// (undocumented)
hasAttribute: typeof predicate_3.hasAttribute, // (undocumented)
hasBox: typeof predicate_3.hasBox, // (undocumented)
hasDisplaySize: typeof predicate_3.hasDisplaySize, // (undocumented)
hasId: typeof predicate_3.hasId, // (undocumented)
hasInputType: typeof predicate_3.hasInputType, // (undocumented)
hasName: typeof predicate_3.hasName, // (undocumented)
hasNamespace: typeof predicate_3.hasNamespace, // (undocumented)
hasTabIndex: typeof predicate_3.hasTabIndex, // (undocumented)
hasAttribute: typeof predicate.hasAttribute, // (undocumented)
hasBox: typeof predicate.hasBox, // (undocumented)
hasDisplaySize: typeof predicate.hasDisplaySize, // (undocumented)
hasId: typeof predicate.hasId, // (undocumented)
hasInputType: typeof predicate.hasInputType, // (undocumented)
hasName: typeof predicate.hasName, // (undocumented)
hasNamespace: typeof predicate.hasNamespace, // (undocumented)
hasTabIndex: typeof predicate.hasTabIndex, // (undocumented)
hasUniqueId: Predicate<Element<string>>, // (undocumented)
isBrowsingContextContainer: typeof predicate_3.isBrowsingContextContainer, // (undocumented)
isContent: typeof predicate_3.isContent, // (undocumented)
isActuallyDisabled: typeof predicate_3.isActuallyDisabled, // (undocumented)
isDocumentElement: typeof predicate_3.isDocumentElement, // (undocumented)
isDraggable: typeof predicate_3.isDraggable, // (undocumented)
isEditingHost: typeof predicate_3.isEditingHost, // (undocumented)
isFallback: typeof predicate_3.isFallback, // (undocumented)
isScopedTo: typeof predicate_3.isScopedTo, // (undocumented)
isSuggestedFocusable: typeof predicate_3.isSuggestedFocusable, // (undocumented)
isReplaced: typeof predicate_3.isReplaced;
isBrowsingContextContainer: typeof predicate.isBrowsingContextContainer, // (undocumented)
isContent: typeof predicate.isContent, // (undocumented)
isActuallyDisabled: typeof predicate.isActuallyDisabled, // (undocumented)
isDocumentElement: typeof predicate.isDocumentElement, // (undocumented)
isDraggable: typeof predicate.isDraggable, // (undocumented)
isEditingHost: typeof predicate.isEditingHost, // (undocumented)
isFallback: typeof predicate.isFallback, // (undocumented)
isScopedTo: typeof predicate.isScopedTo, // (undocumented)
isSuggestedFocusable: typeof predicate.isSuggestedFocusable, // (undocumented)
isReplaced: typeof predicate.isReplaced;
// (undocumented)
export interface MinimalJSON extends Node.JSON<"element"> {
}
Expand Down
79 changes: 79 additions & 0 deletions docs/review/api/alfa-test-deprecated.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
## API Report File for "@siteimprove/alfa-test-deprecated"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

// @public (undocumented)
export interface Assertions {
// (undocumented)
<T>(value: T, message?: string): void;
// (undocumented)
deepEqual<T>(actual: T, expected: T, message?: string): void;
// (undocumented)
equal<T>(actual: T, expected: T, message?: string): void;
// (undocumented)
fail(message?: string): never;
// (undocumented)
notDeepEqual<T>(actual: T, expected: T, message?: string): void;
// (undocumented)
notEqual<T>(actual: T, expected: T, message?: string): void;
// (undocumented)
rejects<T>(block: Function | Promise<T>, error?: RegExp | Function | Object | Error, message?: string): void;
// (undocumented)
throws(block: Function, error?: RegExp | Function | Object | Error, message?: string): void;
}

// @public (undocumented)
export interface Controller<T = number> {
// (undocumented)
iterations: number;
// (undocumented)
seed?: number;
// (undocumented)
wrapper: (rng: RNG<number>, iteration: number) => RNG<T>;
}

// Warning: (ae-internal-missing-underscore) The name "defaultController" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const defaultController: Controller<number>;

// Warning: (ae-internal-missing-underscore) The name "format" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function format(name: string, error: Error): string;

// Warning: (ae-internal-missing-underscore) The name "Notifier" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface Notifier {
// (undocumented)
error(message: string): void;
}

// @public (undocumented)
export type RNG<T = number> = () => T;

// Warning: (ae-internal-missing-underscore) The name "seedableRNG" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export function seedableRNG(seed: number): RNG<number>;

// Warning: (ae-forgotten-export) The symbol "Frame" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "stack" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function stack(error: Error): Iterable<Frame>;

// Warning: (ae-internal-mixed-release-tag) Mixed release tags are not allowed for "test" because one of its declarations is marked as @internal
//
// @public (undocumented)
export function test<T = number>(name: string, assertion: (assert: Assertions, rng: RNG<T>, seed: number) => void | Promise<void>, controller?: Partial<Controller<T>>): Promise<void>;

// @internal (undocumented)
export function test<T = number>(name: string, assertion: (assert: Assertions, rng: RNG<T>, seed: number) => void | Promise<void>, notifier: Notifier, controller?: Partial<Controller<T>>): Promise<void>;

// (No @packageDocumentation comment for this package)

```
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "node --max-old-space-size=8192 scripts/build.mjs --pretty",
"clean": "node scripts/clean.mjs --pretty",
"test": "node scripts/test.mjs --pretty",
"test": "yarn build && vitest run --config ./config/vitest.config.ts",
"watch": "node scripts/watch.mjs --pretty",
"extract": "node scripts/api-extractor.mjs --pretty",
"document": "api-documenter generate -i docs/data/api -o docs/api",
Expand All @@ -32,15 +32,13 @@
"@microsoft/api-documenter": "^7.19.9",
"@microsoft/api-extractor": "^7.29.5",
"@siteimprove/alfa-toolchain": "workspace:^0.94.1",
"@types/async": "^3.2.20",
"@types/node": "^22.0.0",
"async": "^3.2.1",
"execa": "^9.0.0",
"knip": "^5.23.1",
"minimist": "^1.2.6",
"package-dependency-graph": "^1.14.4",
"prettier": "^3.0.0",
"typescript": "^5.5.2"
"typescript": "^5.5.2",
"vitest": "^2.1.5"
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/alfa-affine/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./transformation.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-aria/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@siteimprove/alfa-dom",
"outDir": "."
"noEmit": true
},
"files": [
"./dom/predicate/has-accessible-name.spec.tsx",
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-branched/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./branched.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-cache/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./cache.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-cascade/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": ".",
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@siteimprove/alfa-dom"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-comparable/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./comparable.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-css-feature/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": [
"./media.spec.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-css/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": [
"./common/parse.ts",
Expand Down
2 changes: 2 additions & 0 deletions packages/alfa-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"./jsx.js": "./dist/jsx.js",
"./jsx-runtime": "./dist/jsx-runtime.js",
"./jsx-runtime.js": "./dist/jsx-runtime.js",
"./jsx-dev-runtime": "./dist/jsx-runtime.js",
"./jsx-dev-runtime.js": "./dist/jsx-runtime.js",
"./native": "./dist/native.js",
"./native.js": "./dist/native.js"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ export * from "./node/type.js";

export * from "./node/query/index.js";

export * from "./h.js";
export { h } from "./h.js";
export * from "./jsx.js";
2 changes: 1 addition & 1 deletion packages/alfa-dom/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": ".",
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@siteimprove/alfa-dom"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-emitter/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./emitter.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-equatable/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./equatable.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-flags/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./flags.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-fnv/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./fnv.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-future/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./future.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-generator/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./generator.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-graph/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./graph.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-http/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./request.spec.ts", "./response.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-iana/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./language.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-lazy/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./lazy.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-list/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "."
"noEmit": true
},
"files": ["./list.spec.ts"],
"references": [{ "path": "../src" }, { "path": "../../alfa-test" }]
Expand Down
Loading

0 comments on commit de60ce9

Please sign in to comment.