Skip to content

Commit

Permalink
feat(vitest) use vitest instead of react-scripts for tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <david.edler@canonical.com>
  • Loading branch information
edlerd committed Jan 23, 2024
1 parent 224632b commit 36f2e4d
Show file tree
Hide file tree
Showing 12 changed files with 755 additions and 5,973 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"hooks-remove": "husky uninstall",
"start": "concurrently --kill-others --raw 'vite --host | grep -v 3000' 'yarn serve'",
"serve": "./entrypoint",
"test-js": "react-scripts test src/ --watchAll=false"
"test-js": "vitest --run"
},
"dependencies": {
"@canonical/react-components": "0.47.3",
Expand All @@ -38,7 +38,6 @@
"react-cytoscapejs": "2.0.0",
"react-dom": "18.2.0",
"react-router-dom": "6.21.3",
"react-scripts": "5.0.1",
"react-useportal": "1.0.19",
"serve": "14.2.1",
"vanilla-framework": "4.6.0",
Expand Down Expand Up @@ -83,7 +82,8 @@
"stylelint-scss": "6.0.0",
"typescript": "5.3.3",
"vite": "4.5.2",
"vite-tsconfig-paths": "4.3.1"
"vite-tsconfig-paths": "4.3.1",
"vitest": "1.2.1"
},
"lint-staged": {
"src/**/*.{json,jsx,ts,tsx}": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions tests/devices.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ test("profile edit custom volumes", async ({ page }) => {
await saveProfile(page);

await page.getByRole("row", { name: "Size 3GiB" }).click();
if (await page.getByRole("gridcell", { name: volume }).isVisible()) {
fail("Volume is still present");
}

const volumeVisible = await page
.getByRole("gridcell", { name: volume })
.isVisible();
test.fail(volumeVisible, "Volume is still present");

await deleteProfile(page, profile);
await deleteVolume(page, volume);
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"sourceMap": true
"sourceMap": true,
"types": ["vitest/globals"]
},
"include": [
"./src",
Expand All @@ -35,6 +36,7 @@
"playwright.config.ts",
"webpack.config.js",
"./tests/*.ts",
"vite.config.ts"
"vite.config.ts",
"vitest.config.ts"
],
}
12 changes: 12 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { mergeConfig, defineConfig } from "vitest/config";
import viteConfig from "./vite.config";

export default mergeConfig(
viteConfig,
defineConfig({
test: {
globals: true,
include: ["./src/**/*.spec.{ts,tsx}"],
},
}),
);
6,696 changes: 731 additions & 5,965 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 36f2e4d

Please sign in to comment.