diff --git a/docs/development-guide/08-testing.md b/docs/development-guide/08-testing.md index 9ce93c1169b..4a025ce90f4 100644 --- a/docs/development-guide/08-testing.md +++ b/docs/development-guide/08-testing.md @@ -19,7 +19,7 @@ yarn test Or you can run the tests in watch mode with: ``` -yarn test --watch +yarn test:watch ``` To run a specific file or files in a directory: diff --git a/package.json b/package.json index e84e1d54952..b4fbea4ca1f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "license": "Apache-2.0", "devDependencies": { "husky": "^9.1.6", - "typescript": "^5.5.4" + "typescript": "^5.5.4", + "vitest": "^2.1.1" }, "scripts": { "lint": "yarn run eslint . --quiet --ext .js,.ts,.tsx", @@ -23,7 +24,12 @@ "start:manager": "yarn workspace linode-manager start", "start:manager:ci": "yarn workspace linode-manager start:ci", "clean": "rm -rf node_modules && rm -rf packages/@linode/api-v4/node_modules && rm -rf packages/manager/node_modules && rm -rf packages/@linode/validation/node_modules", - "test": "yarn workspace linode-manager test", + "test": "vitest run", + "test:watch": "vitest", + "test:manager": "yarn workspace linode-manager test", + "test:sdk": "yarn workspace @linode/api-v4 test", + "test:search": "yarn workspace @linode/search test", + "test:ui": "yarn workspace @linode/ui test", "package-versions": "node ./scripts/package-versions/index.js", "storybook": "yarn workspace linode-manager storybook", "cy:run": "yarn workspace linode-manager cy:run", diff --git a/packages/api-v4/package.json b/packages/api-v4/package.json index af5ed8c861a..aab5a0bbb41 100644 --- a/packages/api-v4/package.json +++ b/packages/api-v4/package.json @@ -64,8 +64,7 @@ "eslint-plugin-sonarjs": "^0.5.0", "lint-staged": "^15.2.9", "prettier": "~2.2.1", - "tsup": "^8.2.4", - "vitest": "^2.1.1" + "tsup": "^8.2.4" }, "lint-staged": { "*.{ts,tsx,js}": [ diff --git a/packages/manager/.changeset/pr-11184-tests-1730217933343.md b/packages/manager/.changeset/pr-11184-tests-1730217933343.md new file mode 100644 index 00000000000..711c71f5d18 --- /dev/null +++ b/packages/manager/.changeset/pr-11184-tests-1730217933343.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tests +--- + +Add vitest workspace configuration ([#11184](https://github.com/linode/manager/pull/11184)) diff --git a/packages/manager/.storybook/utils.test.ts b/packages/manager/.storybook/utils.test.ts index f21815e432e..9dc8db75c2b 100644 --- a/packages/manager/.storybook/utils.test.ts +++ b/packages/manager/.storybook/utils.test.ts @@ -3,25 +3,24 @@ import { getReactDocgenTSFileGlobs } from './utils'; describe('getReactDocgenTSFileGlobs', () => { const typeScriptFileGlobs = getReactDocgenTSFileGlobs(); it('should return component and feature globs for storybook files', () => { - console.log(typeScriptFileGlobs); expect( - typeScriptFileGlobs.some( - (file) => file === '../manager/src/components/Button/**/*.{ts,tsx}' + typeScriptFileGlobs.some((file) => + file.includes('../manager/src/components/Button/**/*.{ts,tsx}') ) ).toBe(true); expect( - typeScriptFileGlobs.some( - (file) => file === '../manager/src/components/Paper.{ts,tsx}' + typeScriptFileGlobs.some((file) => + file.includes('../manager/src/components/Paper.{ts,tsx}') ) ).toBe(true); expect( - typeScriptFileGlobs.some( - (file) => file === '../manager/src/features/TopMenu/**/*.{ts,tsx}' + typeScriptFileGlobs.some((file) => + file.includes('../manager/src/features/TopMenu/**/*.{ts,tsx}') ) ).toBe(true); expect( - typeScriptFileGlobs.some( - (file) => file === '../manager/src/features/Longview/**/*.{ts,tsx}' + typeScriptFileGlobs.some((file) => + file.includes('../manager/src/features/Longview/**/*.{ts,tsx}') ) ).toBe(false); }); diff --git a/packages/manager/.storybook/utils.ts b/packages/manager/.storybook/utils.ts index e0024ef61fe..5e2686d5665 100644 --- a/packages/manager/.storybook/utils.ts +++ b/packages/manager/.storybook/utils.ts @@ -1,6 +1,6 @@ import globby from 'globby'; -const PATTERN = '../**/src/**/*.stories.tsx'; +const PATTERN = __dirname + '/../../**/src/**/*.stories.tsx'; /** * Find all storybook files, then return the glob containing the parent component/feature. diff --git a/packages/manager/package.json b/packages/manager/package.json index cd2f8f3543d..f015ff79750 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -209,8 +209,7 @@ "storybook-dark-mode": "4.0.1", "tsx": "^4.19.1", "vite": "^5.4.6", - "vite-plugin-svgr": "^3.2.0", - "vitest": "^2.1.1" + "vite-plugin-svgr": "^3.2.0" }, "browserslist": [ ">1%", diff --git a/packages/search/package.json b/packages/search/package.json index 7d29bf499e8..1ba6459f292 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -18,8 +18,5 @@ "peerDependencies": { "@linode/api-v4": "*", "vite": "*" - }, - "devDependencies": { - "vitest": "^2.1.1" } } diff --git a/packages/ui/package.json b/packages/ui/package.json index 787d09ef2b2..11fa556f13e 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -54,7 +54,6 @@ "eslint-plugin-prettier": "~3.3.1", "eslint-plugin-sonarjs": "^0.5.0", "lint-staged": "^15.2.9", - "prettier": "~2.2.1", - "vitest": "^2.1.1" + "prettier": "~2.2.1" } } diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 00000000000..f34924fbad8 --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1,6 @@ +export default [ + 'packages/manager', + 'packages/api-v4', + 'packages/ui', + 'packages/search', +] \ No newline at end of file