Skip to content

Commit

Permalink
test: [M3-8809] - Add vitest workspace configuration (#11184)
Browse files Browse the repository at this point in the history
* Add vitest workspace configuration

* Added changeset: Add vitest workspace configuration

* Remove vitest from package devDependencies and add search package

* Update docs and add watch command @bnussman-akamai
  • Loading branch information
hkhalil-akamai authored Oct 31, 2024
1 parent 08b752d commit 308dc90
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/development-guide/08-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions packages/api-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}": [
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11184-tests-1730217933343.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add vitest workspace configuration ([#11184](https://github.com/linode/manager/pull/11184))
17 changes: 8 additions & 9 deletions packages/manager/.storybook/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/.storybook/utils.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 1 addition & 2 deletions packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%",
Expand Down
3 changes: 0 additions & 3 deletions packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@
"peerDependencies": {
"@linode/api-v4": "*",
"vite": "*"
},
"devDependencies": {
"vitest": "^2.1.1"
}
}
3 changes: 1 addition & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 6 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default [
'packages/manager',
'packages/api-v4',
'packages/ui',
'packages/search',
]

0 comments on commit 308dc90

Please sign in to comment.