Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
node-version: 22
cache: yarn
- run: yarn --frozen-lockfile
- run: yarn test:mocha
- run: yarn test:vitest
- run: yarn test:tsc
- run: yarn test:lint
- run: yarn test:prettier
Expand Down
24 changes: 6 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"src/**/*.js"
],
"scripts": {
"test": "yarn test:mocha && yarn test:tsc && yarn test:lint && yarn test:prettier",
"test:coverage": "c8 yarn test:mocha",
"test:mocha": "mkdir -p test/output && TZ=America/Los_Angeles tsx node_modules/.bin/mocha 'test/**/*-test.*' 'test/plot.*'",
"test": "yarn test:vitest && yarn test:tsc && yarn test:lint && yarn test:prettier",
"test:coverage": "TZ=America/Los_Angeles vitest run --coverage",
"test:vitest": "TZ=America/Los_Angeles vitest run",
"test:lint": "eslint src test",
"test:prettier": "prettier --check src test",
"test:tsc": "tsc",
Expand All @@ -52,12 +52,11 @@
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@types/d3": "^7.4.0",
"@types/mocha": "^10.0.1",
"@types/node": "^22.13.2",
"@typescript-eslint/eslint-plugin": "^8.24.0",
"@typescript-eslint/parser": "^8.24.0",
"@vitest/coverage-v8": "^4.0.18",
"apache-arrow": "^19.0.0",
"c8": "^10.1.3",
"canvas": "^3.1.0",
"d3-geo-projection": "^4.0.0",
"eslint": "^9.20.1",
Expand All @@ -67,25 +66,14 @@
"js-beautify": "1",
"jsdom": "^26.0.0",
"markdown-it-container": "^4.0.0",
"mocha": "^11.1.0",
"prettier": "~3.0.0",
"rollup": "^4.9.1",
"topojson-client": "^3.1.0",
"ts-morph": "^25.0.1",
"tsx": "^4.7.0",
"typescript": "^5.0.2",
"vite": "^6.1.0",
"vitepress": "^1.3.1"
},
"c8": {
"all": true,
"include": [
"src/**/*.js"
],
"reporter": [
"text",
"lcov"
]
"vitepress": "^1.3.1",
"vitest": "^4.0.8"
},
"dependencies": {
"d3": "^7.9.0",
Expand Down
2 changes: 1 addition & 1 deletion test/assert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import {assert} from "vitest";

function warns(run, expected = /warning/i) {
const actual = [];
Expand Down
2 changes: 1 addition & 1 deletion test/docs-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import {assert, it} from "vitest";
import {readMarkdownFiles, readMarkdownSource, getAnchors, getLinks} from "../docs/components/links.js";

it("documentation links point to existing internal anchors", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/document-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";
import {JSDOM} from "jsdom";

it("Plot.plot supports the document option", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/event-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import * as assert from "assert";
import {JSDOM} from "jsdom";

it("Plot uses the context’s event", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/facet-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";
import assert from "./assert.js";
import it from "./jsdom.js";
import {it} from "vitest";

it("mark data parallel to facet data triggers a warning", async () => {
const data = await d3.csv("data/anscombe.csv", d3.autoType);
Expand Down
2 changes: 1 addition & 1 deletion test/interval-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import {assert, describe, it} from "vitest";
import {numberInterval} from "../src/options.js";

describe("numberInterval(interval)", () => {
Expand Down
54 changes: 0 additions & 54 deletions test/jsdom.js

This file was deleted.

3 changes: 1 addition & 2 deletions test/legend-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Plot from "@observablehq/plot";
import * as assert from "assert";
import it from "./jsdom.js";
import {assert, it} from "vitest";

it(`Plot.legend({color: {type: "identity"}}) returns undefined`, () => {
assert.strictEqual(Plot.legend({color: {type: "identity"}}), undefined);
Expand Down
13 changes: 6 additions & 7 deletions test/mark-test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import * as Plot from "@observablehq/plot";
import assert from "assert";
import it from "./jsdom.js";
import {assert, it} from "vitest";

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

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

it("mark(data, {sort}) rejects an invalid order", () => {
assert.throws(() => Plot.dotY([0, 1], {sort: {y: {value: "x", order: "neo" as any}}}).plot(), /^Error: invalid order: neo$/); // prettier-ignore
assert.throws(() => Plot.dotY([0, 1], {sort: {y: {value: "x", order: "neo" as any}}}).plot(), /invalid order: neo$/); // prettier-ignore
});
2 changes: 1 addition & 1 deletion test/marks/area-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import {curveLinear, curveStep} from "d3";
import assert from "assert";

it("area(data, options) has the expected defaults", () => {
const area = Plot.area(undefined, {x1: "0", y1: "1"});
Expand Down
2 changes: 1 addition & 1 deletion test/marks/auto-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("Plot.autoSpec makes a histogram from a quantitative dimension", () => {
const data = [{value: 1}, {value: 1}, {value: 38}];
Expand Down
2 changes: 1 addition & 1 deletion test/marks/bar-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("barX() has the expected defaults", () => {
const bar = Plot.barX();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/cell-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("cell() has the expected defaults", () => {
const cell = Plot.cell();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/dot-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("dot() has the expected defaults", () => {
const dot = Plot.dot();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/format-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("formatNumber(locale) does the right thing", () => {
assert.strictEqual(Plot.formatNumber()(Math.PI), "3.142");
Expand Down
2 changes: 1 addition & 1 deletion test/marks/frame-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("frame(options) has the expected defaults", () => {
const frame = Plot.frame();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/image-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("image(undefined, {src}) has the expected defaults", () => {
const image = Plot.image(undefined, {src: "foo"});
Expand Down
6 changes: 3 additions & 3 deletions test/marks/line-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import {curveStep} from "d3";
import {curveAuto} from "../../src/curve.js";
import assert from "assert";

it("line() has the expected defaults", () => {
const line = Plot.line();
Expand Down Expand Up @@ -117,8 +117,8 @@ it("line(data, {curve}) specifies a named curve or function", () => {
});

it("line(data, {curve}) rejects an invalid curve", () => {
assert.throws(() => Plot.lineY([], {y: 1, curve: "neo"}), /^Error: unknown curve: neo$/);
assert.throws(() => Plot.lineY([], {y: 1, curve: 42}), /^Error: unknown curve: 42$/);
assert.throws(() => Plot.lineY([], {y: 1, curve: "neo"}), /unknown curve: neo$/);
assert.throws(() => Plot.lineY([], {y: 1, curve: 42}), /unknown curve: 42$/);
});

it("line(data, {curve}) accepts the explicit auto curve", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/marks/link-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("link(data, options) has the expected defaults", () => {
const link = Plot.link(undefined, {x1: "0", y1: "1", x2: "2", y2: "3"});
Expand Down
2 changes: 1 addition & 1 deletion test/marks/memoize-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, describe, it} from "vitest";
import {memoize1} from "../../src/memoize.js";
import assert from "assert";

describe("memoize1(compute)", () => {
it("returns the cached value with repeated calls", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/marks/rect-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("rect(data, options) has the expected defaults", () => {
const rect = Plot.rect(undefined, {x1: "0", y1: "1", x2: "2", y2: "3"});
Expand Down
3 changes: 1 addition & 2 deletions test/marks/rule-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Plot from "@observablehq/plot";
import assert from "assert";
import it from "../jsdom.js";
import {assert, it} from "vitest";

it("ruleX() has the expected defaults", () => {
const rule = Plot.ruleX();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/text-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import {clipEnd, clipMiddle, clipStart, defaultWidth, readCharacter} from "../../src/marks/text.js";
import assert from "assert";

it("text() has the expected defaults", () => {
const text = Plot.text();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/tick-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("tickX() has the expected defaults", () => {
const tick = Plot.tickX();
Expand Down
2 changes: 1 addition & 1 deletion test/marks/time-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import {assert, it} from "vitest";
import * as d3 from "d3";
import {timeInterval, utcInterval} from "../../src/time.js";

Expand Down
3 changes: 3 additions & 0 deletions test/options-d-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {it} from "vitest";
import {valueof} from "../src/options.js";

it.skip("type-only tests, checked by tsc", () => {});

// A function is not a valid input data
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
Expand Down
2 changes: 1 addition & 1 deletion test/options-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import {assert, it} from "vitest";
import {identity, isNumericString, valueof} from "../src/options.js";

it("isNumericString detects numeric strings", () => {
Expand Down
7 changes: 3 additions & 4 deletions test/plot-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as Plot from "@observablehq/plot";
import assert from "assert";
import it from "./jsdom.js";
import {assert, it} from "vitest";

it("plot({aspectRatio}) rejects unsupported scale types", () => {
assert.throws(() => Plot.dot([]).plot({aspectRatio: true, x: {type: "symlog"}}), /^Error: unsupported x scale for aspectRatio: symlog$/); // prettier-ignore
assert.throws(() => Plot.dot([]).plot({aspectRatio: true, y: {type: "symlog"}}), /^Error: unsupported y scale for aspectRatio: symlog$/); // prettier-ignore
assert.throws(() => Plot.dot([]).plot({aspectRatio: true, x: {type: "symlog"}}), /unsupported x scale for aspectRatio: symlog$/); // prettier-ignore
assert.throws(() => Plot.dot([]).plot({aspectRatio: true, y: {type: "symlog"}}), /unsupported y scale for aspectRatio: symlog$/); // prettier-ignore
});
Loading