Skip to content

Commit

Permalink
Refactor jest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot committed Feb 9, 2024
1 parent 9faad13 commit b5f8e60
Show file tree
Hide file tree
Showing 184 changed files with 1,125 additions and 1,379 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Build libraries and distributions
run: pnpm build

- name: Types
run: pnpm types:check

format:
needs: [build]
runs-on: ubuntu-latest
Expand All @@ -46,16 +49,6 @@ jobs:
- name: Lint
run: pnpm lint

types:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Types Check
run: pnpm types:check

test:
needs: [build]
runs-on: ubuntu-latest
Expand Down
14 changes: 0 additions & 14 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* `package.json:scripts`.
*/

const path = require("path");
const PKG_SRC = path.resolve("src");

// For publishing, use the core package's version.
const coreVersion = require("./packages/victory-core/package.json").version;
if (!coreVersion) {
Expand Down Expand Up @@ -60,17 +57,6 @@ module.exports = {
"lint:pkg": 'nps "lint:base src"',
"lint:pkg:fix": 'nps "lint:base --fix src"',

// Tests
// - Jest
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
"jest:native": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-native-config.js --passWithNoTests --testPathPattern=${PKG_SRC}`,
"jest:pkg": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-config.js --passWithNoTests --testPathPattern=${PKG_SRC}`,
// TODO(2348): Hook coverage up to CI
// https://github.com/FormidableLabs/victory/issues/2348
// TODO(2348): Add this to `check:ci`
"jest:cov": "echo TODO",

// - TypeScript
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
Expand Down
26 changes: 6 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/react-native": "^11.0.0",
"@types/fs-extra": "^11.0.3",
"@types/jest": "^28.1.6",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.14.149",
"@types/node": "^18.6.1",
"@types/prop-types": "^15.7.5",
Expand All @@ -64,7 +64,7 @@
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"babel-jest": "^28.1.3",
"babel-jest": "^29.7.0",
"babel-loader": "^8.2.5",
"babel-plugin-lodash": "^3.1.2",
"babel-plugin-module-resolver": "^4.1.0",
Expand All @@ -87,8 +87,8 @@
"fs-extra": "^10.0.0",
"glob": "8.0.3",
"immutable": "^3.8.2",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lodash": "^4.17.19",
"lodash-webpack-plugin": "^0.11.6",
"mdast-util-to-string": "^1.0.6",
Expand All @@ -107,7 +107,7 @@
"seedrandom": "^3.0.5",
"storybook": "^7.6.7",
"styled-components": "^5.3.5",
"ts-jest": "^28.0.7",
"ts-jest": "^29.1.2",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.3",
Expand Down Expand Up @@ -163,7 +163,7 @@
"storybook:server": "concurrently --raw \"pnpm:build:lib:esm --watch\" \"pnpx storybook dev -p 6006\"",
"sync": "wireit",
"sync:pkgs": "node ./scripts/sync-pkgs-wireit.js",
"sync:tsconfig": "pnpm -r --filter !victory-core --filter !victory-vendor exec -- cpx ../victory-core/tsconfig.* .",
"sync:tsconfig": "pnpm -r --filter !victory-core --filter !victory-vendor --filter !victory-native exec -- cpx ../victory-core/tsconfig.* .",
"release-notes": "ts-node ./scripts/release.ts"
},
"wireit": {
Expand Down Expand Up @@ -422,23 +422,9 @@
},
"jest": {
"dependencies": [
"jest:root",
"jest:pkgs"
]
},
"jest:root": {
"command": "jest --testPathPattern=test/node",
"files": [
"test"
],
"output": [],
"dependencies": [
"./packages/victory:build:lib:cjs"
],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"jest:pkgs": {
"dependencies": [
"./packages/victory-native:jest",
Expand Down
5 changes: 5 additions & 0 deletions packages/victory-area/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rootConfig from "../../test/jest.config";

export default {
...rootConfig,
};
13 changes: 6 additions & 7 deletions packages/victory-area/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"react": ">=16.6.0"
},
"devDependencies": {
"victory-chart": "*",
"victory-area": "*"
"victory-chart": "*"
},
"publishConfig": {
"provenance": true
Expand Down Expand Up @@ -275,7 +274,7 @@
]
},
"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [
"src/**/*.test.*",
"../../.babelrc.js",
Expand All @@ -284,10 +283,10 @@
],
"output": [],
"dependencies": [
"build:lib:cjs",
"../victory-chart:build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"
"../victory-core:build",
"../victory-vendor:build",
"../victory-chart:build",
"../victory-voronoi:build"
],
"packageLocks": [
"pnpm-lock.yaml"
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-area/src/area.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import { Area } from "victory-area";
import { render } from "@testing-library/react";
import { VictoryContainer } from "victory-core";
import * as d3Scale from "victory-vendor/d3-scale";

import { Area } from "./area";

describe("victory-primitives/area", () => {
const baseProps = {
data: [
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-area/src/helper-methods.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getDataWithBaseline } from "victory-area/lib/helper-methods";
import * as d3Scale from "victory-vendor/d3-scale";

import { getDataWithBaseline } from "./helper-methods";

describe("victory-area/helper-methods", () => {
describe("getDataWithBaseline", () => {
const data = [
Expand Down
4 changes: 3 additions & 1 deletion packages/victory-area/src/victory-area.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import { Area, VictoryArea, VictoryAreaProps } from "victory-area";
import { VictoryChart } from "victory-chart";
import { Helpers } from "victory-core";
import { curveCatmullRom } from "victory-vendor/d3-shape";

import { calculateD3Path } from "../../../test/helpers/svg";
import { Area } from "./area";
import { VictoryArea, VictoryAreaProps } from "./victory-area";

describe("components/victory-area", () => {
describe("default component rendering", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-area/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*", "es", "lib"]
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/victory-area/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["es", "lib"]
"exclude": ["es", "lib", "jest.config.ts"]
}
5 changes: 5 additions & 0 deletions packages/victory-axis/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rootConfig from "../../test/jest.config";

export default {
...rootConfig,
};
11 changes: 4 additions & 7 deletions packages/victory-axis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"peerDependencies": {
"react": ">=16.6.0"
},
"devDependencies": {
"victory-axis": "*"
},
"publishConfig": {
"provenance": true
},
Expand Down Expand Up @@ -263,7 +260,7 @@
]
},
"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [
"src/**/*.test.*",
"../../.babelrc.js",
Expand All @@ -272,9 +269,9 @@
],
"output": [],
"dependencies": [
"build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"
"../victory-core:build",
"../victory-vendor:build",
"../victory-voronoi:build"
],
"packageLocks": [
"pnpm-lock.yaml"
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-axis/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*", "es", "lib"]
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/victory-axis/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["es", "lib"]
"exclude": ["es", "lib", "jest.config.ts"]
}
5 changes: 5 additions & 0 deletions packages/victory-bar/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rootConfig from "../../test/jest.config";

export default {
...rootConfig,
};
13 changes: 6 additions & 7 deletions packages/victory-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"react": ">=16.6.0"
},
"devDependencies": {
"victory-chart": "*",
"victory-bar": "*"
"victory-chart": "*"
},
"publishConfig": {
"provenance": true
Expand Down Expand Up @@ -275,7 +274,7 @@
]
},
"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [
"src/**/*.test.*",
"../../.babelrc.js",
Expand All @@ -284,10 +283,10 @@
],
"output": [],
"dependencies": [
"build:lib:cjs",
"../victory-chart:build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"
"../victory-core:build",
"../victory-vendor:build",
"../victory-chart:build",
"../victory-voronoi:build"
],
"packageLocks": [
"pnpm-lock.yaml"
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-bar/src/bar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from "react";
import { render } from "@testing-library/react";
import * as d3Scale from "victory-vendor/d3-scale";
import { VictoryContainer } from "victory-core";
import { Bar } from "victory-bar";

import { getBarShape } from "../../../test/helpers";
import { Bar } from "./bar";

describe("victory-primitives/bar", () => {
const baseProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-bar/src/geometry-helper-methods.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { circle, point } from "victory-bar/lib/geometry-helper-methods";
import { circle, point } from "./geometry-helper-methods";

describe("point", () => {
describe("calculates distances", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-bar/src/victory-bar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import { VictoryChart } from "victory-chart";
import { Bar, VictoryBar } from "victory-bar";
import { Helpers } from "victory-core";

import { isBar, getBarHeight } from "../../../test/helpers";
import { Bar } from "./bar";
import { VictoryBar } from "./victory-bar";

describe("components/victory-bar", () => {
describe("default component rendering", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-bar/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*", "es", "lib"]
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/victory-bar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["es", "lib"]
"exclude": ["es", "lib", "jest.config.ts"]
}
5 changes: 5 additions & 0 deletions packages/victory-box-plot/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rootConfig from "../../test/jest.config";

export default {
...rootConfig,
};
11 changes: 5 additions & 6 deletions packages/victory-box-plot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"react": ">=16.6.0"
},
"devDependencies": {
"victory-box-plot": "*",
"victory-chart": "*"
},
"publishConfig": {
Expand Down Expand Up @@ -275,7 +274,7 @@
]
},
"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [
"src/**/*.test.*",
"../../.babelrc.js",
Expand All @@ -284,10 +283,10 @@
],
"output": [],
"dependencies": [
"build:lib:cjs",
"../victory-chart:build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"
"../victory-core:build",
"../victory-vendor:build",
"../victory-chart:build",
"../victory-voronoi:build"
],
"packageLocks": [
"pnpm-lock.yaml"
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-box-plot/src/victory-box-plot.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { render, screen } from "@testing-library/react";
import React from "react";
import { VictoryBoxPlot } from "victory-box-plot";
import { VictoryChart } from "victory-chart";
import { Border, LineSegment, Whisker } from "victory-core";

import { VictoryBoxPlot } from "./victory-box-plot";

const TEST_GROUP_ID = "test-group-id";
const dataset = [
{ x: 1, min: 1, max: 18, median: 8, q1: 5, q3: 15 },
Expand Down
Loading

0 comments on commit b5f8e60

Please sign in to comment.