Skip to content

Commit b65a298

Browse files
committed
adopt vitest; substitute images if they approximately match the expected images
1 parent 33a3ea1 commit b65a298

42 files changed

Lines changed: 778 additions & 630 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"src/**/*.js"
2828
],
2929
"scripts": {
30-
"test": "yarn test:mocha && yarn test:tsc && yarn test:lint && yarn test:prettier",
31-
"test:coverage": "c8 yarn test:mocha",
32-
"test:mocha": "mkdir -p test/output && TZ=America/Los_Angeles tsx node_modules/.bin/mocha 'test/**/*-test.*' 'test/plot.*'",
30+
"test": "yarn test:vitest && yarn test:tsc && yarn test:lint && yarn test:prettier",
31+
"test:coverage": "TZ=America/Los_Angeles vitest run --coverage",
32+
"test:vitest": "TZ=America/Los_Angeles vitest run",
3333
"test:lint": "eslint src test",
3434
"test:prettier": "prettier --check src test",
3535
"test:tsc": "tsc",
@@ -52,12 +52,11 @@
5252
"@rollup/plugin-node-resolve": "^16.0.0",
5353
"@rollup/plugin-terser": "^0.4.0",
5454
"@types/d3": "^7.4.0",
55-
"@types/mocha": "^10.0.1",
5655
"@types/node": "^22.13.2",
5756
"@typescript-eslint/eslint-plugin": "^8.24.0",
5857
"@typescript-eslint/parser": "^8.24.0",
58+
"@vitest/coverage-v8": "^4.0.18",
5959
"apache-arrow": "^19.0.0",
60-
"c8": "^10.1.3",
6160
"canvas": "^3.1.0",
6261
"d3-geo-projection": "^4.0.0",
6362
"eslint": "^9.20.1",
@@ -67,25 +66,14 @@
6766
"js-beautify": "1",
6867
"jsdom": "^26.0.0",
6968
"markdown-it-container": "^4.0.0",
70-
"mocha": "^11.1.0",
7169
"prettier": "~3.0.0",
7270
"rollup": "^4.9.1",
7371
"topojson-client": "^3.1.0",
7472
"ts-morph": "^25.0.1",
75-
"tsx": "^4.7.0",
7673
"typescript": "^5.0.2",
7774
"vite": "^6.1.0",
78-
"vitepress": "^1.3.1"
79-
},
80-
"c8": {
81-
"all": true,
82-
"include": [
83-
"src/**/*.js"
84-
],
85-
"reporter": [
86-
"text",
87-
"lcov"
88-
]
75+
"vitepress": "^1.3.1",
76+
"vitest": "^4.0.8"
8977
},
9078
"dependencies": {
9179
"d3": "^7.9.0",

test/assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from "assert";
1+
import {assert} from "vitest";
22

33
function warns(run, expected = /warning/i) {
44
const actual = [];

test/docs-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from "assert";
1+
import {assert, it} from "vitest";
22
import {readMarkdownFiles, readMarkdownSource, getAnchors, getLinks} from "../docs/components/links.js";
33

44
it("documentation links point to existing internal anchors", async () => {

test/document-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import {assert, it} from "vitest";
12
import * as Plot from "@observablehq/plot";
2-
import assert from "assert";
33
import {JSDOM} from "jsdom";
44

55
it("Plot.plot supports the document option", () => {

test/event-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import {assert, it} from "vitest";
12
import * as Plot from "@observablehq/plot";
2-
import * as assert from "assert";
33
import {JSDOM} from "jsdom";
44

55
it("Plot uses the context’s event", () => {

test/facet-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Plot from "@observablehq/plot";
22
import * as d3 from "d3";
33
import assert from "./assert.js";
4-
import it from "./jsdom.js";
4+
import {it} from "vitest";
55

66
it("mark data parallel to facet data triggers a warning", async () => {
77
const data = await d3.csv("data/anscombe.csv", d3.autoType);

test/interval-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from "assert";
1+
import {assert, describe, it} from "vitest";
22
import {numberInterval} from "../src/options.js";
33

44
describe("numberInterval(interval)", () => {

test/jsdom.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

test/legend-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as Plot from "@observablehq/plot";
2-
import * as assert from "assert";
3-
import it from "./jsdom.js";
2+
import {assert, it} from "vitest";
43

54
it(`Plot.legend({color: {type: "identity"}}) returns undefined`, () => {
65
assert.strictEqual(Plot.legend({color: {type: "identity"}}), undefined);

test/mark-test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import * as Plot from "@observablehq/plot";
2-
import assert from "assert";
3-
import it from "./jsdom.js";
2+
import {assert, it} from "vitest";
43

54
it("mark(data, {sort}) needs y1 and y2 when sorting by height", () => {
6-
assert.throws(() => Plot.dot([], {sort: {x: "height"}}).plot(), /^Error: missing channel: y1$/);
7-
assert.throws(() => Plot.dot([], {channels: {y1: "1"}, sort: {x: "height"}}).plot(), /^Error: missing channel: y2$/);
5+
assert.throws(() => Plot.dot([], {sort: {x: "height"}}).plot(), /missing channel: y1$/);
6+
assert.throws(() => Plot.dot([], {channels: {y1: "1"}, sort: {x: "height"}}).plot(), /missing channel: y2$/);
87
});
98

109
it("mark(data, {sort}) needs x1 and x2 when sorting by width", () => {
11-
assert.throws(() => Plot.dot([], {sort: {y: "width"}}).plot(), /^Error: missing channel: x1$/);
12-
assert.throws(() => Plot.dot([], {channels: {x1: "1"}, sort: {y: "width"}}).plot(), /^Error: missing channel: x2$/);
10+
assert.throws(() => Plot.dot([], {sort: {y: "width"}}).plot(), /missing channel: x1$/);
11+
assert.throws(() => Plot.dot([], {channels: {x1: "1"}, sort: {y: "width"}}).plot(), /missing channel: x2$/);
1312
});
1413

1514
it("mark(data, {sort}) rejects an invalid order", () => {
16-
assert.throws(() => Plot.dotY([0, 1], {sort: {y: {value: "x", order: "neo" as any}}}).plot(), /^Error: invalid order: neo$/); // prettier-ignore
15+
assert.throws(() => Plot.dotY([0, 1], {sort: {y: {value: "x", order: "neo" as any}}}).plot(), /invalid order: neo$/); // prettier-ignore
1716
});

0 commit comments

Comments
 (0)