Skip to content

Commit 7bb575a

Browse files
authored
Refactor jest configuration (#2796)
1 parent 9faad13 commit 7bb575a

File tree

184 files changed

+1131
-1375
lines changed

Some content is hidden

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

184 files changed

+1131
-1375
lines changed

.github/workflows/ci.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: Build libraries and distributions
2727
run: pnpm build
2828

29+
- name: Types
30+
run: pnpm types:check
31+
2932
format:
3033
needs: [build]
3134
runs-on: ubuntu-latest
@@ -46,16 +49,6 @@ jobs:
4649
- name: Lint
4750
run: pnpm lint
4851

49-
types:
50-
needs: [build]
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: actions/checkout@v4
54-
- uses: ./.github/actions/setup
55-
56-
- name: Types Check
57-
run: pnpm types:check
58-
5952
test:
6053
needs: [build]
6154
runs-on: ubuntu-latest

package-scripts.js

-14
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
* `package.json:scripts`.
1313
*/
1414

15-
const path = require("path");
16-
const PKG_SRC = path.resolve("src");
17-
1815
// For publishing, use the core package's version.
1916
const coreVersion = require("./packages/victory-core/package.json").version;
2017
if (!coreVersion) {
@@ -60,17 +57,6 @@ module.exports = {
6057
"lint:pkg": 'nps "lint:base src"',
6158
"lint:pkg:fix": 'nps "lint:base --fix src"',
6259

63-
// Tests
64-
// - Jest
65-
// TODO(2375): Can we cache / incremental?
66-
// https://github.com/FormidableLabs/victory/issues/2375
67-
"jest:native": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-native-config.js --passWithNoTests --testPathPattern=${PKG_SRC}`,
68-
"jest:pkg": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-config.js --passWithNoTests --testPathPattern=${PKG_SRC}`,
69-
// TODO(2348): Hook coverage up to CI
70-
// https://github.com/FormidableLabs/victory/issues/2348
71-
// TODO(2348): Add this to `check:ci`
72-
"jest:cov": "echo TODO",
73-
7460
// - TypeScript
7561
// TODO(2375): Can we cache / incremental?
7662
// https://github.com/FormidableLabs/victory/issues/2375

package.json

+6-20
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@testing-library/react-hooks": "^8.0.0",
5656
"@testing-library/react-native": "^11.0.0",
5757
"@types/fs-extra": "^11.0.3",
58-
"@types/jest": "^28.1.6",
58+
"@types/jest": "^29.5.12",
5959
"@types/lodash": "^4.14.149",
6060
"@types/node": "^18.6.1",
6161
"@types/prop-types": "^15.7.5",
@@ -64,7 +64,7 @@
6464
"@types/testing-library__jest-dom": "^5.14.5",
6565
"@typescript-eslint/eslint-plugin": "^5.32.0",
6666
"@typescript-eslint/parser": "^5.32.0",
67-
"babel-jest": "^28.1.3",
67+
"babel-jest": "^29.7.0",
6868
"babel-loader": "^8.2.5",
6969
"babel-plugin-lodash": "^3.1.2",
7070
"babel-plugin-module-resolver": "^4.1.0",
@@ -87,8 +87,8 @@
8787
"fs-extra": "^10.0.0",
8888
"glob": "8.0.3",
8989
"immutable": "^3.8.2",
90-
"jest": "^28.1.3",
91-
"jest-environment-jsdom": "^28.1.3",
90+
"jest": "^29.7.0",
91+
"jest-environment-jsdom": "^29.7.0",
9292
"lodash": "^4.17.19",
9393
"lodash-webpack-plugin": "^0.11.6",
9494
"mdast-util-to-string": "^1.0.6",
@@ -107,7 +107,7 @@
107107
"seedrandom": "^3.0.5",
108108
"storybook": "^7.6.7",
109109
"styled-components": "^5.3.5",
110-
"ts-jest": "^28.0.7",
110+
"ts-jest": "^29.1.2",
111111
"ts-loader": "^9.3.0",
112112
"ts-node": "^10.9.1",
113113
"typescript": "^4.7.3",
@@ -163,7 +163,7 @@
163163
"storybook:server": "concurrently --raw \"pnpm:build:lib:esm --watch\" \"pnpx storybook dev -p 6006\"",
164164
"sync": "wireit",
165165
"sync:pkgs": "node ./scripts/sync-pkgs-wireit.js",
166-
"sync:tsconfig": "pnpm -r --filter !victory-core --filter !victory-vendor exec -- cpx ../victory-core/tsconfig.* .",
166+
"sync:tsconfig": "pnpm -r --filter !victory-core --filter !victory-vendor --filter !victory-native exec -- cpx ../victory-core/tsconfig.* .",
167167
"release-notes": "ts-node ./scripts/release.ts"
168168
},
169169
"wireit": {
@@ -422,23 +422,9 @@
422422
},
423423
"jest": {
424424
"dependencies": [
425-
"jest:root",
426425
"jest:pkgs"
427426
]
428427
},
429-
"jest:root": {
430-
"command": "jest --testPathPattern=test/node",
431-
"files": [
432-
"test"
433-
],
434-
"output": [],
435-
"dependencies": [
436-
"./packages/victory:build:lib:cjs"
437-
],
438-
"packageLocks": [
439-
"pnpm-lock.yaml"
440-
]
441-
},
442428
"jest:pkgs": {
443429
"dependencies": [
444430
"./packages/victory-native:jest",

packages/victory-area/jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rootConfig from "../../test/jest.config";
2+
3+
export default {
4+
...rootConfig,
5+
};

packages/victory-area/package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"react": ">=16.6.0"
2929
},
3030
"devDependencies": {
31-
"victory-chart": "*",
32-
"victory-area": "*"
31+
"victory-chart": "*"
3332
},
3433
"publishConfig": {
3534
"provenance": true
@@ -275,7 +274,7 @@
275274
]
276275
},
277276
"jest": {
278-
"command": "nps jest:pkg",
277+
"command": "jest --passWithNoTests",
279278
"files": [
280279
"src/**/*.test.*",
281280
"../../.babelrc.js",
@@ -284,10 +283,10 @@
284283
],
285284
"output": [],
286285
"dependencies": [
287-
"build:lib:cjs",
288-
"../victory-chart:build:lib:cjs",
289-
"../victory-vendor:build:lib:cjs",
290-
"../victory-voronoi:build:lib:cjs"
286+
"../victory-core:build",
287+
"../victory-vendor:build",
288+
"../victory-chart:build",
289+
"../victory-voronoi:build"
291290
],
292291
"packageLocks": [
293292
"pnpm-lock.yaml"

packages/victory-area/src/area.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from "react";
2-
import { Area } from "victory-area";
32
import { render } from "@testing-library/react";
43
import { VictoryContainer } from "victory-core";
54
import * as d3Scale from "victory-vendor/d3-scale";
65

6+
import { Area } from "./area";
7+
78
describe("victory-primitives/area", () => {
89
const baseProps = {
910
data: [

packages/victory-area/src/helper-methods.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { getDataWithBaseline } from "victory-area/lib/helper-methods";
21
import * as d3Scale from "victory-vendor/d3-scale";
32

3+
import { getDataWithBaseline } from "./helper-methods";
4+
45
describe("victory-area/helper-methods", () => {
56
describe("getDataWithBaseline", () => {
67
const data = [

packages/victory-area/src/victory-area.test.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { fireEvent, render, screen } from "@testing-library/react";
22
import React from "react";
3-
import { Area, VictoryArea, VictoryAreaProps } from "victory-area";
43
import { VictoryChart } from "victory-chart";
54
import { Helpers } from "victory-core";
65
import { curveCatmullRom } from "victory-vendor/d3-shape";
6+
77
import { calculateD3Path } from "../../../test/helpers/svg";
8+
import { Area } from "./area";
9+
import { VictoryArea, VictoryAreaProps } from "./victory-area";
810

911
describe("components/victory-area", () => {
1012
describe("default component rendering", () => {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["**/*.test.*", "es", "lib"]
3+
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
44
}

packages/victory-area/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["es", "lib"]
3+
"exclude": ["es", "lib", "jest.config.ts"]
44
}

packages/victory-axis/jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rootConfig from "../../test/jest.config";
2+
3+
export default {
4+
...rootConfig,
5+
};

packages/victory-axis/package.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
"peerDependencies": {
2727
"react": ">=16.6.0"
2828
},
29-
"devDependencies": {
30-
"victory-axis": "*"
31-
},
3229
"publishConfig": {
3330
"provenance": true
3431
},
@@ -263,7 +260,7 @@
263260
]
264261
},
265262
"jest": {
266-
"command": "nps jest:pkg",
263+
"command": "jest --passWithNoTests",
267264
"files": [
268265
"src/**/*.test.*",
269266
"../../.babelrc.js",
@@ -272,9 +269,9 @@
272269
],
273270
"output": [],
274271
"dependencies": [
275-
"build:lib:cjs",
276-
"../victory-vendor:build:lib:cjs",
277-
"../victory-voronoi:build:lib:cjs"
272+
"../victory-core:build",
273+
"../victory-vendor:build",
274+
"../victory-voronoi:build"
278275
],
279276
"packageLocks": [
280277
"pnpm-lock.yaml"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["**/*.test.*", "es", "lib"]
3+
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
44
}

packages/victory-axis/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["es", "lib"]
3+
"exclude": ["es", "lib", "jest.config.ts"]
44
}

packages/victory-bar/jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rootConfig from "../../test/jest.config";
2+
3+
export default {
4+
...rootConfig,
5+
};

packages/victory-bar/package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"react": ">=16.6.0"
2929
},
3030
"devDependencies": {
31-
"victory-chart": "*",
32-
"victory-bar": "*"
31+
"victory-chart": "*"
3332
},
3433
"publishConfig": {
3534
"provenance": true
@@ -275,7 +274,7 @@
275274
]
276275
},
277276
"jest": {
278-
"command": "nps jest:pkg",
277+
"command": "jest --passWithNoTests",
279278
"files": [
280279
"src/**/*.test.*",
281280
"../../.babelrc.js",
@@ -284,10 +283,10 @@
284283
],
285284
"output": [],
286285
"dependencies": [
287-
"build:lib:cjs",
288-
"../victory-chart:build:lib:cjs",
289-
"../victory-vendor:build:lib:cjs",
290-
"../victory-voronoi:build:lib:cjs"
286+
"../victory-core:build",
287+
"../victory-vendor:build",
288+
"../victory-chart:build",
289+
"../victory-voronoi:build"
291290
],
292291
"packageLocks": [
293292
"pnpm-lock.yaml"

packages/victory-bar/src/bar.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import React from "react";
22
import { render } from "@testing-library/react";
33
import * as d3Scale from "victory-vendor/d3-scale";
44
import { VictoryContainer } from "victory-core";
5-
import { Bar } from "victory-bar";
5+
66
import { getBarShape } from "../../../test/helpers";
7+
import { Bar } from "./bar";
78

89
describe("victory-primitives/bar", () => {
910
const baseProps = {

packages/victory-bar/src/geometry-helper-methods.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { circle, point } from "victory-bar/lib/geometry-helper-methods";
1+
import { circle, point } from "./geometry-helper-methods";
22

33
describe("point", () => {
44
describe("calculates distances", () => {

packages/victory-bar/src/victory-bar.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as React from "react";
22
import { render, fireEvent, screen } from "@testing-library/react";
33
import { VictoryChart } from "victory-chart";
4-
import { Bar, VictoryBar } from "victory-bar";
54
import { Helpers } from "victory-core";
65

76
import { isBar, getBarHeight } from "../../../test/helpers";
7+
import { Bar } from "./bar";
8+
import { VictoryBar } from "./victory-bar";
89

910
describe("components/victory-bar", () => {
1011
describe("default component rendering", () => {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["**/*.test.*", "es", "lib"]
3+
"exclude": ["**/*.test.*", "es", "lib", "jest.config.ts"]
44
}

packages/victory-bar/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"exclude": ["es", "lib"]
3+
"exclude": ["es", "lib", "jest.config.ts"]
44
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rootConfig from "../../test/jest.config";
2+
3+
export default {
4+
...rootConfig,
5+
};

packages/victory-box-plot/package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"react": ">=16.6.0"
2929
},
3030
"devDependencies": {
31-
"victory-box-plot": "*",
3231
"victory-chart": "*"
3332
},
3433
"publishConfig": {
@@ -275,7 +274,7 @@
275274
]
276275
},
277276
"jest": {
278-
"command": "nps jest:pkg",
277+
"command": "jest --passWithNoTests",
279278
"files": [
280279
"src/**/*.test.*",
281280
"../../.babelrc.js",
@@ -284,10 +283,10 @@
284283
],
285284
"output": [],
286285
"dependencies": [
287-
"build:lib:cjs",
288-
"../victory-chart:build:lib:cjs",
289-
"../victory-vendor:build:lib:cjs",
290-
"../victory-voronoi:build:lib:cjs"
286+
"../victory-core:build",
287+
"../victory-vendor:build",
288+
"../victory-chart:build",
289+
"../victory-voronoi:build"
291290
],
292291
"packageLocks": [
293292
"pnpm-lock.yaml"

packages/victory-box-plot/src/victory-box-plot.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { render, screen } from "@testing-library/react";
22
import React from "react";
3-
import { VictoryBoxPlot } from "victory-box-plot";
43
import { VictoryChart } from "victory-chart";
54
import { Border, LineSegment, Whisker } from "victory-core";
65

6+
import { VictoryBoxPlot } from "./victory-box-plot";
7+
78
const TEST_GROUP_ID = "test-group-id";
89
const dataset = [
910
{ x: 1, min: 1, max: 18, median: 8, q1: 5, q3: 15 },

0 commit comments

Comments
 (0)