Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tests to root directories #2301

Merged
merged 27 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
552878f
Move tests to root directories
Jun 14, 2022
86abe77
Fix test helper imports
Jun 14, 2022
1e112e3
chore(typescript): exclude tests from TS compilation
Jun 15, 2022
beef5d2
chore(typescript): added `tsconfig.build.json` to every package
Jun 15, 2022
a38c198
Add ts tests to babel ignore command
Jun 15, 2022
44aa243
Add separate babel build config that ignores test files
Jun 15, 2022
0e36e9b
Remove .d.ts ignore from babel build configuration and delete .test.d…
Jun 15, 2022
969b41d
Add eslint ignore comments for empty functions (this rule is not over…
Jun 15, 2022
9dd7777
Fix typecheck errors
Jun 15, 2022
862cd22
Remove separate test eslint config
Jun 15, 2022
c67eb5d
Move victory native tests
Jun 15, 2022
37195cb
Move victory vendor tests
Jun 15, 2022
8d65419
Remove tsconfig comments
Jun 15, 2022
8f6cd5c
Remove no-copy-ignored flag
Jun 16, 2022
a7bbb97
Add tests to npmignore files
Jun 16, 2022
9c5099b
Separate out copying .d.ts files, add watch support
ryan-roemer Jun 16, 2022
a4a3666
chore(build): simplified watch scripts to run for single packages
Jun 17, 2022
7c797ba
Merge pull request #2305 from FormidableLabs/chore/move-tests-moar-build
scottrippey Jun 17, 2022
e30ce85
Merge remote-tracking branch 'origin/main' into chore/move-tests
Jun 20, 2022
c48f051
chore(tests): fix lint
Jun 21, 2022
7ac2209
chore(tests): fix named imports
Jun 21, 2022
ae82992
chore(tests): don't transpile compiled code
Jun 21, 2022
f3fd02f
chore(build): refactored "watch" scripts, to be closer to their source
Jun 21, 2022
379b9c6
chore(build): ignore TypeScript errors during build
Jun 21, 2022
6668c41
Fix babel jest regex and remove relative imports
Jun 21, 2022
a3fec9a
Fix typecheck error
Jun 21, 2022
d5f6ec1
Update remaining relative imports
Jun 21, 2022
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
4 changes: 4 additions & 0 deletions .babelrc.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: "./.babelrc.js",
ignore: [/^.*(.test.)[j|t]sx?$/]
};
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@ module.exports = {
"jest/globals": true
},
overrides: [
{
files: ["**/*.test.*", "./test/**/*"],
rules: {
"react/sort-comp": "off",
"no-magic-numbers": 0,
"max-statements": 0,
"import/no-unresolved": 0,
"no-undef": "off",
"max-nested-callbacks": "off",
"@typescript-eslint/no-empty-function": "off",
"react/prop-types": "off"
}
},
becca-bailey marked this conversation as resolved.
Show resolved Hide resolved
{
files: ["*.ts", "*.tsx"],
excludedFiles: ["*.d.ts"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.base.json"],
// eslint-disable-next-line no-undef
tsconfigRootDir: __dirname
},
plugins: ["@typescript-eslint"],
Expand Down
8 changes: 2 additions & 6 deletions jest-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testMatch: ["**/jest/**/?(*.)+(test).[jt]s?(x)"],
testPathIgnorePatterns: ["victory-native"],
testPathIgnorePatterns: ["victory-native", "node_modules", "config"],
transform: {
"^.+/test/.+\\.(ts|tsx|js|jsx)$": [
"babel-jest",
{ configFile: "./.babelrc.js" }
]
"\\.[jt]sx?$": ["babel-jest", { configFile: "./.babelrc.js" }]
scottrippey marked this conversation as resolved.
Show resolved Hide resolved
},
setupFilesAfterEnv: ["<rootDir>/test/jest-setup.js"]
};
2 changes: 1 addition & 1 deletion jest-native-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testMatch: ["**/jest/victory-native/**/?(*.)+(spec|test).[jt]s?(x)"],
testMatch: ["**/*/victory-native/**/?(*.)+(spec|test).[jt]s?(x)"],
transform: {
// TODO(2215): Switch over to only transpiling from within `/test/`
// https://github.com/FormidableLabs/victory/issues/2215
Expand Down
16 changes: 8 additions & 8 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ module.exports = {
},
typecheck: {
default: npsUtils.series.nps("typecheck.packages", "typecheck.test"),
base: "tsc --noEmit",
core: "lerna exec --scope victory-core -- nps typecheck.base",
src: "tsc --noEmit",
demo: "tsc -p ./demo/tsconfig.json --noEmit",
test: "tsc -p ./test/tsconfig.json --noEmit",
packages: "lerna exec --ignore victory-vendor -- nps typecheck.base"
core: "lerna exec --scope victory-core -- nps typecheck.src",
packages: "lerna exec --ignore victory-vendor -- nps typecheck.src"
},
types: {
base: "tsc --emitDeclarationOnly --rootDir src",
base: "tsc -p ./tsconfig.build.json --emitDeclarationOnly --rootDir src",
lib: "nps types.base -- -- --outDir lib",
es: "nps types.base -- -- --outDir es"
},
Expand All @@ -95,8 +95,8 @@ module.exports = {
default: npsUtils.series.nps("lint", "test")
},
watch: {
es: "lerna exec --parallel --ignore victory-native --ignore victory-vendor -- cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.js --copy-files --extensions .tsx,.ts,.jsx,.js --watch",
lib: "lerna exec --parallel --ignore victory-native --ignore victory-vendor -- cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.js --copy-files --extensions .tsx,.ts,.jsx,.js --watch",
es: "lerna exec --parallel --ignore victory-native --ignore victory-vendor -- cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.build.js --copy-files --no-copy-ignored --extensions .tsx,.ts,.jsx,.js --watch",
lib: "lerna exec --parallel --ignore victory-native --ignore victory-vendor -- cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.build.js --copy-files --no-copy-ignored --extensions .tsx,.ts,.jsx,.js --watch",
scottrippey marked this conversation as resolved.
Show resolved Hide resolved
core: npsUtils.concurrent.nps("watch.es", "watch.lib"),
// `victory-vendor` is built 1x up front and not watched.
default: npsUtils.series.nps("build-package-libs-vendor", "watch.core")
Expand All @@ -113,9 +113,9 @@ module.exports = {
"lerna version --no-git-tag-version --no-push --loglevel silly",
// TODO: organize build scripts once build perf is sorted out
"babel-es":
"cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.js --copy-files --extensions .tsx,.ts,.jsx,.js",
"cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.build.js --copy-files --no-copy-ignored --extensions .tsx,.ts,.jsx,.js",
"babel-lib":
"cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.js --copy-files --extensions .tsx,.ts,.jsx,.js",
"cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.build.js --copy-files --no-copy-ignored --extensions .tsx,.ts,.jsx,.js",
"build-es": npsUtils.series.nps("clean.es", "babel-es", "types.es"),
"build-lib": npsUtils.series.nps("clean.lib", "babel-lib", "types.lib"),
"build-libs": npsUtils.series.nps("build-lib", "build-es"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Area } from "victory-area";
import Area from "./area";
import { merge } from "lodash";
import { render } from "@testing-library/react";
import { VictoryContainer } from "victory-core";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDataWithBaseline } from "victory-area/lib/helper-methods";
import { getDataWithBaseline } from "./helper-methods";
becca-bailey marked this conversation as resolved.
Show resolved Hide resolved
import * as d3Scale from "victory-vendor/d3-scale";

describe("victory-area/helper-methods", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import { Area, VictoryArea } from "victory-area";
import { VictoryChart } from "victory-chart";
import { curveCatmullRom } from "victory-vendor/d3-shape";
import { calculateD3Path } from "../../svg-test-helper";
import { calculateD3Path } from "../../../test/helpers";

describe("components/victory-area", () => {
describe("default component rendering", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/victory-area/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
4 changes: 4 additions & 0 deletions packages/victory-axis/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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 "../../svg-test-helper";
import Bar from "./bar";
import { getBarShape } from "../../../test/helpers";

describe("victory-primitives/bar", () => {
const baseProps = {
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*eslint-disable max-nested-callbacks */

import React from "react";
import * as React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import { range } from "lodash";
import { VictoryChart } from "victory-chart";
import { VictoryBar, Bar } from "victory-bar";
import { isBar, getBarHeight } from "../../svg-test-helper";
import VictoryBar from "./victory-bar";
import Bar from "./bar";
import { isBar, getBarHeight } from "../../../test/helpers";

describe("components/victory-bar", () => {
describe("default component rendering", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/victory-bar/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*eslint-disable react/prop-types */
import { render, screen } from "@testing-library/react";
import React from "react";
import { VictoryBoxPlot } from "victory-box-plot";
import VictoryBoxPlot from "./victory-box-plot";
import { VictoryChart } from "victory-chart";
import { Border, LineSegment, Whisker } from "victory-core";

Expand Down
4 changes: 4 additions & 0 deletions packages/victory-box-plot/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { BrushHelpers } from "victory-brush-container";
import Helpers from "./brush-helpers";

describe("containers/brush-helpers", () => {
const { withinBounds, constrainBox } = BrushHelpers;

const { withinBounds, constrainBox } = Helpers;
describe("withinBounds", () => {
it("returns true when within bounds", () => {
const point = { x: 1, y: 1 };
Expand Down
4 changes: 4 additions & 0 deletions packages/victory-brush-container/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
4 changes: 4 additions & 0 deletions packages/victory-brush-line/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { render } from "@testing-library/react";
import { Candle } from "victory-candlestick";
import Candle from "./candle";
import { VictoryContainer } from "victory-core";
import * as d3Scale from "victory-vendor/d3-scale";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint max-nested-callbacks: 0 */
import { range } from "lodash";
import { fromJS } from "immutable";
import { getData, getDomain } from "victory-candlestick/lib/helper-methods";
import { getData, getDomain } from "./helper-methods";

const immutableGetDataTest = {
createData: (x) => fromJS(x),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*eslint-disable max-nested-callbacks */
import { fireEvent, render, screen } from "@testing-library/react";
import { range } from "lodash";
import React from "react";
import { Candle, VictoryCandlestick } from "victory-candlestick";
import Candle from "./candle";
import VictoryCandlestick from "./victory-candlestick";
import { VictoryChart } from "victory-chart";

const MyCandle = () => <div data-testid="my-candle" />;
Expand Down
4 changes: 4 additions & 0 deletions packages/victory-candlestick/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
4 changes: 4 additions & 0 deletions packages/victory-canvas/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getChildComponents } from "victory-chart/lib/helper-methods";
import { getChildComponents } from "./helper-methods";
import React from "react";
import { VictoryAxis } from "victory-axis";
import { VictoryLine } from "victory-line";
Expand Down
4 changes: 4 additions & 0 deletions packages/victory-chart/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["**/*.test.*"]
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { render } from "@testing-library/react";
import React from "react";
import { VictoryAccessibleGroup } from "victory-core";
import { VictoryAccessibleGroup } from "./victory-accessible-group";
import { SVGWrapper } from "../../../../test/helpers";

describe("components/victory-accessible-group", () => {
it("renders an g with an aria-label", () => {
const { container } = render(
<VictoryAccessibleGroup aria-label="test-aria-label" />,
{ wrapper: "svg" }
{ wrapper: SVGWrapper }
becca-bailey marked this conversation as resolved.
Show resolved Hide resolved
);
expect(container.querySelector("g")).toMatchInlineSnapshot(`
<g
Expand All @@ -19,7 +20,7 @@ describe("components/victory-accessible-group", () => {
it("renders an g with a tabIndex and className", () => {
const { container } = render(
<VictoryAccessibleGroup tabIndex={5} className="accessibility" />,
{ wrapper: "svg" }
{ wrapper: SVGWrapper }
);
expect(container.querySelector("g")).toMatchInlineSnapshot(`
<g
Expand All @@ -36,7 +37,7 @@ describe("components/victory-accessible-group", () => {
desc="test description"
aria-describedby="describes group"
/>,
{ wrapper: "svg" }
{ wrapper: SVGWrapper }
);
expect(container.querySelector("g")).toMatchInlineSnapshot(`
<g
Expand All @@ -59,7 +60,7 @@ describe("components/victory-accessible-group", () => {
aria-label="desc node tests"
desc="applies to both aria-describedby and descId"
/>,
{ wrapper: "svg" }
{ wrapper: SVGWrapper }
);
expect(container.querySelector("g")).toMatchInlineSnapshot(`
<g
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unused-expressions */
import { victoryInterpolator } from "victory-core/lib/victory-animation/util";
import { victoryInterpolator } from "./util";

describe("victoryInterpolator", () => {
it("does not attempt to interpolate identical values", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { VictoryContainer } from "victory-core";
import { VictoryContainer } from "./victory-container";
import { fireEvent, render } from "@testing-library/react";

describe("components/victory-container", () => {
Expand Down
Loading