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

Migrate to Vitest #491

Merged
merged 9 commits into from
Jul 17, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
- name: Run type, lint, and format checks
run: pnpm checks

- name: Run package tests
run: pnpm test
- name: Run package tests with code coverage
run: pnpm coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vitest.explorer"
]
}
20 changes: 1 addition & 19 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,5 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest current file",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "sh",
"program": "${workspaceFolder}/packages/graph-explorer/node_modules/.bin/jest",
"cwd": "${workspaceFolder}",
"args": [
"${relativeFile}",
"--coverage=false",
"--config=${workspaceFolder}/packages/graph-explorer/jest.config.ts",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "openOnFirstSessionStart"
}
]
"configurations": []
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsdk": "node_modules/typescript/lib",
"jest.rootPath": "packages/graph-explorer/"
"vitest.rootConfig": "packages/graph-explorer/vite.config.ts"
}
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
- Update dependencies (<https://github.com/aws/graph-explorer/pull/475>,
<https://github.com/aws/graph-explorer/pull/486>,
<https://github.com/aws/graph-explorer/pull/490>,
<https://github.com/aws/graph-explorer/pull/492>)
<https://github.com/aws/graph-explorer/pull/492>,
<https://github.com/aws/graph-explorer/pull/491>)

## Release 1.8.0

Expand Down
2 changes: 1 addition & 1 deletion additionaldocs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ root folder in the CLI:
pnpm add react --filter graph-explorer

# Adding a dev only dependency for the server app
pnpm add -D jest --filter graph-explorer-proxy-server
pnpm add -D vitest --filter graph-explorer-proxy-server
```

#### Preparation of a release
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"check:lint": "eslint .",
"format": "prettier --write .",
"check:format": "prettier --check .",
"test": "pnpm -F graph-explorer test",
"test": "pnpm --stream -r run test",
"test:watch": "pnpm --stream -r run test:watch",
"coverage": "pnpm --stream -r run coverage",
"check:types": "tsc --project packages/graph-explorer/",
"checks": "pnpm run '/^check:.*/'",
"start": "pnpm --stream -r run start",
Expand All @@ -36,7 +38,8 @@
"lint-staged": "^13.3.0",
"prettier": "3.2.5",
"typescript": "^5.5.3",
"typescript-eslint": "8.0.0-alpha.42"
"typescript-eslint": "8.0.0-alpha.42",
"vitest": "^2.0.3"
},
"lint-staged": {
"*.{js,ts,tsx}": [
Expand Down
44 changes: 0 additions & 44 deletions packages/graph-explorer/jest.config.ts

This file was deleted.

25 changes: 11 additions & 14 deletions packages/graph-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
},
"type": "module",
"scripts": {
"test": "jest",
"test": "vitest run",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
"dev": "vite",
"clean": "rimraf dist",
"vite-build": "NODE_OPTIONS=--max_old_space_size=6144 vite build",
Expand Down Expand Up @@ -91,7 +93,6 @@
"@babel/preset-env": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"@babel/preset-typescript": "^7.24.1",
"@jest/globals": "29.0.0",
"@react-aria/overlays": "3.9.1",
"@react-stately/radio": "^3.10.3",
"@react-types/button": "^3.9.3",
Expand All @@ -100,17 +101,16 @@
"@react-types/radio": "^3.8.0",
"@react-types/shared": "^3.23.0",
"@react-types/switch": "^3.5.2",
"@testing-library/dom": "^8.20.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^15.0.7",
"@testing-library/dom": "^10.3.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/color": "^3.0.6",
"@types/crypto-js": "^4.2.2",
"@types/cytoscape": "^3.21.0",
"@types/file-saver": "^2.0.7",
"@types/flat": "^5.0.5",
"@types/history": "4.7.11",
"@types/jest": "^26.0.24",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.8",
"@types/papaparse": "^5.3.14",
Expand All @@ -123,23 +123,20 @@
"@types/react-transition-group": "^4.4.10",
"@types/uuid": "^8.3.4",
"@vitejs/plugin-react": "^4.2.1",
"babel-jest": "^29.7.0",
"@vitest/coverage-v8": "^2.0.3",
"buffer": "^6.0.3",
"esbuild-loader": "^2.21.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-github-actions-reporter": "^1.0.3",
"jest-junit": "^16.0.0",
"happy-dom": "^14.12.3",
"jsdom": "^24.1.0",
"lint-staged": "^13.3.0",
"react-test-renderer": "^18.3.1",
"serve": "^14.2.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"type-fest": "^4.18.1",
"vite": "^5.3.3",
"webpack": "^5.91.0",
"whatwg-fetch": "^3.6.20"
"vitest": "^2.0.3",
"webpack": "^5.91.0"
},
"overrides": {
"json5@>=2.0.0 <2.2.2": "2.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mockGremlinFetch from "../../testUtils/mockGremlinFetch";
import fetchNeighbors from "./fetchNeighbors";

describe("Gremlin > fetchNeighbors", () => {
beforeAll(globalMockFetch);
beforeEach(globalMockFetch);

it("Should return all neighbors from node 2018", async () => {
const expectedVertices = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mockGremlinFetch from "../../testUtils/mockGremlinFetch";
import fetchNeighborsCount from "./fetchNeighborsCount";

describe("Gremlin > fetchNeighborsCount", () => {
beforeAll(globalMockFetch);
beforeEach(globalMockFetch);

it("Should return neighbors counts for node 2018", async () => {
const response = await fetchNeighborsCount(mockGremlinFetch(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mockGremlinFetch from "../../testUtils/mockGremlinFetch";
import fetchSchema from "./fetchSchema";

describe("Gremlin > fetchSchema", () => {
beforeAll(globalMockFetch);
beforeEach(globalMockFetch);

it("Should return an inferred schema", async () => {
const schemaResponse = await fetchSchema(mockGremlinFetch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mockGremlinFetch from "../../testUtils/mockGremlinFetch";
import keywordSearch from "./keywordSearch";

describe("Gremlin > keywordSearch", () => {
beforeAll(globalMockFetch);
beforeEach(globalMockFetch);

it("Should return 1 random node", async () => {
const keywordResponse = await keywordSearch(mockGremlinFetch(), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { vi } from "vitest";
import { SchemaResponse } from "../../useGEFetchTypes";
import fetchSchema from "./fetchSchema";

describe("OpenCypher > fetchSchema", () => {
it("Should return a schema", async () => {
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand Down Expand Up @@ -131,7 +132,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponseEmpty)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -157,7 +158,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponseEmpty)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -183,7 +184,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponseEmpty)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -197,7 +198,7 @@ describe("OpenCypher > fetchSchema", () => {
});

it("Should handle empty edge properties", async () => {
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -216,7 +217,7 @@ describe("OpenCypher > fetchSchema", () => {

it("Should handle edges empty response object", async () => {
const allEdgesResponseEmpty = {};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -242,7 +243,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -268,7 +269,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -294,7 +295,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand Down Expand Up @@ -325,7 +326,7 @@ describe("OpenCypher > fetchSchema", () => {
],
};

const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -342,7 +343,7 @@ describe("OpenCypher > fetchSchema", () => {

it("Should handle edges property empty response object", async () => {
const routeEdgePropertiesResponseEmpty = {};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -368,7 +369,7 @@ describe("OpenCypher > fetchSchema", () => {
},
],
};
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -386,7 +387,7 @@ describe("OpenCypher > fetchSchema", () => {
});

it("Should request properties for edges where labels are strings", async () => {
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand All @@ -408,7 +409,7 @@ describe("OpenCypher > fetchSchema", () => {
});

it("Should request properties for edges where labels are arrays of strings", async () => {
const openCypherFetchFn = jest
const openCypherFetchFn = vi
.fn()
.mockResolvedValueOnce(allVertexLabelsResponse)
.mockResolvedValueOnce(airportPropertiesResponse)
Expand Down
Loading
Loading