Skip to content

Commit 0921917

Browse files
anooparvetiaboungnaseng-ovhcloud
authored andcommitted
test(manager-react-components): migrate to common test config
ref: #MANAGER-17983 Signed-off-by: Anoop N <[email protected]>
1 parent 3239826 commit 0921917

File tree

7 files changed

+28
-144
lines changed

7 files changed

+28
-144
lines changed

packages/manager-react-components/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
"dev": "tsc && vite build",
2424
"prepare": "tsc && vite build",
2525
"prettier": "prettier --write \"src/**/*.{ts,tsx,js,mdx}\"",
26-
"test": "TZ=UTC vitest run",
27-
"test:cov": "TZ=UTC vitest run --coverage",
28-
"test:watch": "TZ=UTC vitest"
26+
"test": "TZ=UTC manager-test",
27+
"test:ci": "TZ=UTC manager-test run --coverage"
2928
},
3029
"lint-staged": {
3130
"*.{ts,tsx,js,jsx,json,css,md}": [
@@ -53,12 +52,10 @@
5352
"@ovh-ux/manager-core-utils": "*",
5453
"@ovh-ux/manager-react-shell-client": "^0.8.7",
5554
"@ovh-ux/manager-tailwind-config": "^0.3.0",
55+
"@ovh-ux/manager-tests-setup": "^0.2.0",
5656
"@ovh-ux/manager-vite-config": "^0.10.1",
5757
"@ovhcloud/ods-components": "^18.6.2",
5858
"@ovhcloud/ods-themes": "^18.6.2",
59-
"@testing-library/jest-dom": "6.4.2",
60-
"@testing-library/react": "14.0.0",
61-
"@types/jest": "^29.5.5",
6259
"@types/lodash.isdate": "^4.0.9",
6360
"@types/lodash.isequal": "^4.5.0",
6461
"@types/node": "20.4.9",
@@ -93,13 +90,11 @@
9390
"react-dom": "^18.2.0",
9491
"react-i18next": "^14.0.5",
9592
"react-router-dom": "^6.3.0",
96-
"ts-jest": "^29.1.1",
9793
"typescript": "^4.3.2",
9894
"undici": "5.29.0",
9995
"vite": "^6.0.7",
10096
"vite-plugin-dts": "^4.5.3",
10197
"vite-plugin-static-copy": "^2.3.0",
102-
"vitest": "^3.0.8",
10398
"zustand": "^4.5.5"
10499
},
105100
"peerDependencies": {

packages/manager-react-components/vitest.setup.js renamed to packages/manager-react-components/setupTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// vitest.setup.js
1+
// vitest.setup.ts
22
import '@testing-library/jest-dom';
33
import 'element-internals-polyfill';
44

packages/manager-react-components/src/components/redirection-guard/redirection-guard.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React from 'react';
33
import { render, screen } from '@testing-library/react';
44
import { Navigate } from 'react-router-dom';
55
import { RedirectionGuard } from './redirection-guard.component';
6-
import '@testing-library/jest-dom';
76

87
vi.mock('react-router-dom', () => ({
98
Navigate: vi.fn(() => null),

packages/manager-react-components/src/components/templates/delete-modal/delete-modal.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { waitFor, screen, fireEvent } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44
import { render } from '../../../utils/test.provider';
55
import { DeleteModal, DeleteModalProps } from './delete-modal.component';
6-
import '@testing-library/jest-dom';
76

87
export const sharedProps: DeleteModalProps = {
98
closeModal: vitest.fn(),

packages/manager-react-components/src/hooks/pci/useMaintenance.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import * as useAggregatedPrivateNetworks from './useAggregatedPrivateNetworks';
1212
import * as useProjectRegions from './useProjectRegions';
1313
import { Stein } from './useMigrationSteins';
1414
import { Region } from './useProjectRegions';
15-
import '@testing-library/jest-dom';
1615

1716
const renderUseMaintenanceHook = () => {
1817
const queryClient = new QueryClient();

packages/manager-react-components/vitest.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import path from 'path';
2-
import { defineConfig } from 'vite';
3-
import react from '@vitejs/plugin-react';
4-
// https://vitejs.dev/config/
5-
export default defineConfig({
6-
plugins: [react()],
2+
import {
3+
createConfig,
4+
mergeConfig,
5+
defaultExcludedFiles,
6+
} from '@ovh-ux/manager-tests-setup';
7+
8+
export default mergeConfig(createConfig(), {
79
test: {
8-
setupFiles: 'vitest.setup.js',
10+
setupFiles: 'setupTest.ts',
911
globals: true,
1012
environment: 'jsdom',
1113
coverage: {
1214
include: ['src'],
13-
exclude: [],
15+
exclude: [...defaultExcludedFiles],
1416
},
1517
testTimeout: 60000,
1618
fileParallelism: false,

yarn.lock

Lines changed: 15 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -9667,20 +9667,6 @@
96679667
lz-string "^1.5.0"
96689668
pretty-format "^27.0.2"
96699669

9670-
"@testing-library/[email protected]", "@testing-library/jest-dom@^6.1.5", "@testing-library/jest-dom@^6.2.1", "@testing-library/jest-dom@^6.4.2":
9671-
version "6.4.2"
9672-
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz#38949f6b63722900e2d75ba3c6d9bf8cffb3300e"
9673-
integrity sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==
9674-
dependencies:
9675-
"@adobe/css-tools" "^4.3.2"
9676-
"@babel/runtime" "^7.9.2"
9677-
aria-query "^5.0.0"
9678-
chalk "^3.0.0"
9679-
css.escape "^1.5.1"
9680-
dom-accessibility-api "^0.6.3"
9681-
lodash "^4.17.15"
9682-
redent "^3.0.0"
9683-
96849670
"@testing-library/[email protected]", "@testing-library/jest-dom@^6.5.0":
96859671
version "6.5.0"
96869672
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz#50484da3f80fb222a853479f618a9ce5c47bfe54"
@@ -9709,6 +9695,20 @@
97099695
lodash "^4.17.15"
97109696
redent "^3.0.0"
97119697

9698+
"@testing-library/jest-dom@^6.1.5", "@testing-library/jest-dom@^6.2.1", "@testing-library/jest-dom@^6.4.2":
9699+
version "6.4.2"
9700+
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz#38949f6b63722900e2d75ba3c6d9bf8cffb3300e"
9701+
integrity sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==
9702+
dependencies:
9703+
"@adobe/css-tools" "^4.3.2"
9704+
"@babel/runtime" "^7.9.2"
9705+
aria-query "^5.0.0"
9706+
chalk "^3.0.0"
9707+
css.escape "^1.5.1"
9708+
dom-accessibility-api "^0.6.3"
9709+
lodash "^4.17.15"
9710+
redent "^3.0.0"
9711+
97129712
"@testing-library/jest-dom@^6.2.0", "@testing-library/jest-dom@^6.6.3":
97139713
version "6.6.3"
97149714
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz#26ba906cf928c0f8172e182c6fe214eb4f9f2bd2"
@@ -9744,15 +9744,6 @@
97449744
"@babel/runtime" "^7.12.5"
97459745
react-error-boundary "^3.1.0"
97469746

9747-
"@testing-library/[email protected]":
9748-
version "14.0.0"
9749-
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-14.0.0.tgz#59030392a6792450b9ab8e67aea5f3cc18d6347c"
9750-
integrity sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==
9751-
dependencies:
9752-
"@babel/runtime" "^7.12.5"
9753-
"@testing-library/dom" "^9.0.0"
9754-
"@types/react-dom" "^18.0.0"
9755-
97569747
"@testing-library/react@^13.3.0":
97579748
version "13.4.0"
97589749
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.4.0.tgz#6a31e3bf5951615593ad984e96b9e5e2d9380966"
@@ -10141,7 +10132,7 @@
1014110132
dependencies:
1014210133
"@types/istanbul-lib-report" "*"
1014310134

10144-
"@types/jest@*", "@types/jest@^29.5.11", "@types/jest@^29.5.12", "@types/jest@^29.5.5":
10135+
"@types/jest@*", "@types/jest@^29.5.11", "@types/jest@^29.5.12":
1014510136
version "29.5.12"
1014610137
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544"
1014710138
integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==
@@ -11043,16 +11034,6 @@
1104311034
chai "^5.1.2"
1104411035
tinyrainbow "^1.2.0"
1104511036

11046-
11047-
version "3.0.8"
11048-
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.0.8.tgz#53c408180d6476c7363eb976dcaae8e7b1f1a078"
11049-
integrity sha512-Xu6TTIavTvSSS6LZaA3EebWFr6tsoXPetOWNMOlc7LO88QVVBwq2oQWBoDiLCN6YTvNYsGSjqOO8CAdjom5DCQ==
11050-
dependencies:
11051-
"@vitest/spy" "3.0.8"
11052-
"@vitest/utils" "3.0.8"
11053-
chai "^5.2.0"
11054-
tinyrainbow "^2.0.0"
11055-
1105611037
1105711038
version "3.1.3"
1105811039
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.1.3.tgz#bbca175cd2f23d7de9448a215baed8f3d7abd7b7"
@@ -11072,15 +11053,6 @@
1107211053
estree-walker "^3.0.3"
1107311054
magic-string "^0.30.12"
1107411055

11075-
11076-
version "3.0.8"
11077-
resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.0.8.tgz#01638859e7dd422a8aaf04ef63dca9e1bbb9838d"
11078-
integrity sha512-n3LjS7fcW1BCoF+zWZxG7/5XvuYH+lsFg+BDwwAz0arIwHQJFUEsKBQ0BLU49fCxuM/2HSeBPHQD8WjgrxMfow==
11079-
dependencies:
11080-
"@vitest/spy" "3.0.8"
11081-
estree-walker "^3.0.3"
11082-
magic-string "^0.30.17"
11083-
1108411056
1108511057
version "3.1.3"
1108611058
resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.1.3.tgz#121d0f2fcca20c9ccada9e2d6e761f7fc687f4ce"
@@ -11104,13 +11076,6 @@
1110411076
dependencies:
1110511077
tinyrainbow "^1.2.0"
1110611078

11107-
"@vitest/[email protected]", "@vitest/pretty-format@^3.0.8":
11108-
version "3.0.8"
11109-
resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.0.8.tgz#89f6111d141142689871f5a4e62ad679bb6b6357"
11110-
integrity sha512-BNqwbEyitFhzYMYHUVbIvepOyeQOSFA/NeJMIP9enMntkkxLgOcgABH6fjyXG85ipTgvero6noreavGIqfJcIg==
11111-
dependencies:
11112-
tinyrainbow "^2.0.0"
11113-
1111411079
"@vitest/[email protected]", "@vitest/pretty-format@^3.1.3":
1111511080
version "3.1.3"
1111611081
resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.1.3.tgz#760b9eab5f253d7d2e7dcd28ef34570f584023d4"
@@ -11135,14 +11100,6 @@
1113511100
"@vitest/utils" "2.1.9"
1113611101
pathe "^1.1.2"
1113711102

11138-
11139-
version "3.0.8"
11140-
resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.0.8.tgz#dda7223c25a89a829a29c3f0c037a99e028a9c64"
11141-
integrity sha512-c7UUw6gEcOzI8fih+uaAXS5DwjlBaCJUo7KJ4VvJcjL95+DSR1kova2hFuRt3w41KZEFcOEiq098KkyrjXeM5w==
11142-
dependencies:
11143-
"@vitest/utils" "3.0.8"
11144-
pathe "^2.0.3"
11145-
1114611103
1114711104
version "3.1.3"
1114811105
resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.1.3.tgz#b268fa90fca38fab363f1107f057c0a2a141ee45"
@@ -11169,15 +11126,6 @@
1116911126
magic-string "^0.30.12"
1117011127
pathe "^1.1.2"
1117111128

11172-
11173-
version "3.0.8"
11174-
resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.0.8.tgz#b65d738c00ff052a323125ad7dfb001927049c78"
11175-
integrity sha512-x8IlMGSEMugakInj44nUrLSILh/zy1f2/BgH0UeHpNyOocG18M9CWVIFBaXPt8TrqVZWmcPjwfG/ht5tnpba8A==
11176-
dependencies:
11177-
"@vitest/pretty-format" "3.0.8"
11178-
magic-string "^0.30.17"
11179-
pathe "^2.0.3"
11180-
1118111129
1118211130
version "3.1.3"
1118311131
resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.1.3.tgz#39a8f9f8c6ba732ffde59adeacf0a549bef11e76"
@@ -11208,13 +11156,6 @@
1120811156
dependencies:
1120911157
tinyspy "^3.0.2"
1121011158

11211-
11212-
version "3.0.8"
11213-
resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.0.8.tgz#2a31ce28858aae50286644d64f886c72d55ae2ce"
11214-
integrity sha512-MR+PzJa+22vFKYb934CejhR4BeRpMSoxkvNoDit68GQxRLSf11aT6CTj3XaqUU9rxgWJFnqicN/wxw6yBRkI1Q==
11215-
dependencies:
11216-
tinyspy "^3.0.2"
11217-
1121811159
1121911160
version "3.1.3"
1122011161
resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.1.3.tgz#ca81e2b4f0c3d6c75f35defa77c3336f39c8f605"
@@ -11277,15 +11218,6 @@
1127711218
loupe "^3.1.2"
1127811219
tinyrainbow "^1.2.0"
1127911220

11280-
11281-
version "3.0.8"
11282-
resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.0.8.tgz#289277fbd8e733dff69cfa993c34665415c9b66b"
11283-
integrity sha512-nkBC3aEhfX2PdtQI/QwAWp8qZWwzASsU4Npbcd5RdMPBSSLCpkZp52P3xku3s3uA0HIEhGvEcF8rNkBsz9dQ4Q==
11284-
dependencies:
11285-
"@vitest/pretty-format" "3.0.8"
11286-
loupe "^3.1.3"
11287-
tinyrainbow "^2.0.0"
11288-
1128911221
1129011222
version "3.1.3"
1129111223
resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.1.3.tgz#4f31bdfd646cd82d30bfa730d7410cb59d529669"
@@ -16512,11 +16444,6 @@ es-module-lexer@^1.5.4:
1651216444
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.5.4.tgz#a8efec3a3da991e60efa6b633a7cad6ab8d26b78"
1651316445
integrity sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==
1651416446

16515-
es-module-lexer@^1.6.0:
16516-
version "1.6.0"
16517-
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.6.0.tgz#da49f587fd9e68ee2404fe4e256c0c7d3a81be21"
16518-
integrity sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==
16519-
1652016447
es-module-lexer@^1.7.0:
1652116448
version "1.7.0"
1652216449
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.7.0.tgz#9159601561880a85f2734560a9099b2c31e5372a"
@@ -31100,17 +31027,6 @@ [email protected]:
3110031027
pathe "^1.1.2"
3110131028
vite "^5.0.0"
3110231029

31103-
31104-
version "3.0.8"
31105-
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.8.tgz#69cd1e0b9c7c37a8e7ab3b87ce259cbbf9a7bd72"
31106-
integrity sha512-6PhR4H9VGlcwXZ+KWCdMqbtG649xCPZqfI9j2PsK1FcXgEzro5bGHcVKFCTqPLaNKZES8Evqv4LwvZARsq5qlg==
31107-
dependencies:
31108-
cac "^6.7.14"
31109-
debug "^4.4.0"
31110-
es-module-lexer "^1.6.0"
31111-
pathe "^2.0.3"
31112-
vite "^5.0.0 || ^6.0.0"
31113-
3111431030
3111531031
version "3.1.3"
3111631032
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.1.3.tgz#d021ced40b5a057305eaea9ce62c610c33b60a48"
@@ -31318,32 +31234,6 @@ vitest@^2.1.2, vitest@^2.1.9:
3131831234
vite-node "2.1.9"
3131931235
why-is-node-running "^2.3.0"
3132031236

31321-
vitest@^3.0.8:
31322-
version "3.0.8"
31323-
resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.0.8.tgz#2b85e689d3067cf3b8e174626ecfcb8b24be0785"
31324-
integrity sha512-dfqAsNqRGUc8hB9OVR2P0w8PZPEckti2+5rdZip0WIz9WW0MnImJ8XiR61QhqLa92EQzKP2uPkzenKOAHyEIbA==
31325-
dependencies:
31326-
"@vitest/expect" "3.0.8"
31327-
"@vitest/mocker" "3.0.8"
31328-
"@vitest/pretty-format" "^3.0.8"
31329-
"@vitest/runner" "3.0.8"
31330-
"@vitest/snapshot" "3.0.8"
31331-
"@vitest/spy" "3.0.8"
31332-
"@vitest/utils" "3.0.8"
31333-
chai "^5.2.0"
31334-
debug "^4.4.0"
31335-
expect-type "^1.1.0"
31336-
magic-string "^0.30.17"
31337-
pathe "^2.0.3"
31338-
std-env "^3.8.0"
31339-
tinybench "^2.9.0"
31340-
tinyexec "^0.3.2"
31341-
tinypool "^1.0.2"
31342-
tinyrainbow "^2.0.0"
31343-
vite "^5.0.0 || ^6.0.0"
31344-
vite-node "3.0.8"
31345-
why-is-node-running "^2.3.0"
31346-
3134731237
vitest@^3.1.3:
3134831238
version "3.1.3"
3134931239
resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.1.3.tgz#0b0b01932408cd3af61867f4468d28bd83406ffb"

0 commit comments

Comments
 (0)