Skip to content

Commit

Permalink
chore(test): migrate from jest to vitest (#3741)
Browse files Browse the repository at this point in the history
feat(form): migrate form test

feat(form): migrate form test

fix(eslint): remove async error
  • Loading branch information
philibea authored May 21, 2024
1 parent a0f6188 commit 55e5bdf
Show file tree
Hide file tree
Showing 302 changed files with 136,019 additions and 104,193 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ storybook-static
public/
out/
examples/
.vitest/
coverage/
9 changes: 6 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"**/__stories__/**/*.{ts,tsx}",
"**/__tests__/**/*.{ts,tsx}",
"**/vite.config.*",
"utils/test/**/*.{ts,tsx}",
"**/vitest.setup.ts"
],
"extends": ["@scaleway/react/typescript"],
"parserOptions": {
Expand All @@ -40,6 +42,7 @@
"@typescript-eslint/no-unnecessary-condition": "off",
"react/jsx-key": "off",
"import/no-extraneous-dependencies": "off",
"import/no-relative-packages": "off",
"eslint-plugin-import/no-relative-packages": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
Expand All @@ -54,10 +57,10 @@
"extends": ["plugin:testing-library/react"]
},
{
"files": ["*.d.ts", "rollup.config.mjs", "jestMockMatchMedia.ts"],
"files": ["*.d.ts", "vite.config.ts"],
"rules": {
"import/no-extraneous-dependencies": "off"
}
"import/no-extraneous-dependencies": "off",
},
}
]
}
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4 # v4.1.4
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
Expand All @@ -43,7 +43,7 @@ jobs:
matrix:
node: ['20']
steps:
- uses: actions/checkout@v4 # v4.1.4
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: pnpm/[email protected]
Expand All @@ -62,22 +62,22 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

accessibility:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4 # v4.1.4
with:
fetch-depth: '0'
- uses: pnpm/action-setup@v4.0.0
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm install
- run: pnpm run test:a11y
# accessibility:
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: '0'
# - uses: pnpm/action-setup@v3.0.0
# - name: Use Node.js
# uses: actions/[email protected]
# with:
# node-version: 20
# cache: 'pnpm'
# - run: pnpm install
# - run: pnpm run build
# - run: pnpm install
# - run: pnpm run test:a11y
build:
strategy:
matrix:
Expand Down
59 changes: 31 additions & 28 deletions .jest/a11y.config.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import type { Config } from '@jest/types'
import * as path from 'path'
/**
* TODO: Remove when apply new configuration of a11y
*/
// import type { Config } from '@jest/types'
// import * as path from 'path'

const config: Config.InitialOptions = {
rootDir: path.join(__dirname, '..'),
testEnvironment: 'jsdom',
coverageReporters: ['text', 'cobertura'],
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: '.reports',
outputName: 'tests.xml',
},
],
],
transformIgnorePatterns: ['node_modules/(?!@scaleway)/'],
testPathIgnorePatterns: ['/nodes_modules/', 'src/components'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/.jest/fileMock.ts',
'\\.(css|less)$': 'identity-obj-proxy',
'\\.(css\\?inline)$': 'identity-obj-proxy',
},
setupFilesAfterEnv: ['@testing-library/jest-dom'],
testMatch: ['**/a11y.test.tsx'],
}
// const config: Config.InitialOptions = {
// rootDir: path.join(__dirname, '..'),
// testEnvironment: 'jsdom',
// coverageReporters: ['text', 'cobertura'],
// reporters: [
// 'default',
// [
// 'jest-junit',
// {
// outputDirectory: '.reports',
// outputName: 'tests.xml',
// },
// ],
// ],
// transformIgnorePatterns: ['node_modules/(?!@scaleway)/'],
// testPathIgnorePatterns: ['/nodes_modules/', 'src/components'],
// moduleNameMapper: {
// '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
// '<rootDir>/.jest/fileMock.ts',
// '\\.(css|less)$': 'identity-obj-proxy',
// '\\.(css\\?inline)$': 'identity-obj-proxy',
// },
// setupFilesAfterEnv: ['@testing-library/jest-dom'],
// testMatch: ['**/a11y.test.tsx'],
// }

export default config
// export default config
40 changes: 0 additions & 40 deletions .jest/setupTests.ts

This file was deleted.

36 changes: 0 additions & 36 deletions .jest/unit.config.ts

This file was deleted.

1 change: 1 addition & 0 deletions .vitest/fileMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'test-file-stub'
2 changes: 2 additions & 0 deletions .vitest/svg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default 'SvgrURL'
export const ReactComponent = 'div'
2 changes: 1 addition & 1 deletion examples/next-advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@babel/core": "7.24.5",
"@types/node": "18.19.33",
"@types/react": "18.3.2",
"@types/react": "18.3.1",
"next-transpile-modules": "10.0.1",
"@types/react-syntax-highlighter": "15.5.13"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/next-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"devDependencies": {
"@babel/core": "7.24.5",
"@types/node": "18.19.33",
"@types/react": "18.3.2",
"@types/react": "18.3.1",
"@types/react-syntax-highlighter": "15.5.13",
"next-transpile-modules": "10.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/next-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@babel/core": "7.24.5",
"@types/node": "18.19.33",
"@types/react": "18.3.2",
"@types/react": "18.3.1",
"next-transpile-modules": "10.0.1",
"@types/react-syntax-highlighter": "15.5.13"
}
Expand Down
29 changes: 10 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
"format": "prettier --write '**/*.{ts,tsx,js,json,md,mdx}'",
"lint:fix": "pnpm run lint --fix",
"lint": "eslint --report-unused-disable-directives --cache --ext js,mjs,ts,tsx .",
"test:unit": "LC_ALL=en_US.UTF-8 jest --config .jest/unit.config.ts",
"test:unit:coverage": "pnpm run test:unit --coverage",
"test:unit:watch": "pnpm run test:unit --watch",
"test:unit:update": "pnpm run test:unit --updateSnapshot",
"test:a11y": "LC_ALL=en_US.UTF-8 jest --config .jest/a11y.config.ts",
"prebuild": "pnpm --filter '@ultraviolet/*' recursive run prebuild",
"test:unit": "pnpm --filter '@ultraviolet/*' recursive run test:unit",
"test:unit:coverage": "pnpm --filter '@ultraviolet/*' recursive run test:unit:coverage",
"prepare": "husky",
"size": "pnpm run build && size-limit",
"size:packages": "pnpm --filter '@ultraviolet/*' recursive run size",
Expand Down Expand Up @@ -82,13 +80,6 @@
"react": "18",
"react-dom": "18"
}
},
"packageExtensions": {
"jest": {
"dependencies": {
"ts-node": "10.9.2"
}
}
}
},
"devDependencies": {
Expand All @@ -110,10 +101,7 @@
"@emotion/jest": "11.11.0",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"@jest/globals": "29.7.0",
"@jest/types": "29.6.3",
"@scaleway/eslint-config-react": "3.18.2",
"@scaleway/jest-helpers": "4.0.2",
"@scaleway/tsconfig": "1.1.1",
"@scaleway/use-i18n": "6.1.6",
"@size-limit/file": "11.1.4",
Expand All @@ -139,14 +127,16 @@
"@testing-library/react": "15.0.7",
"@testing-library/user-event": "14.5.2",
"@types/node": "18.19.33",
"@types/react": "18.3.2",
"@types/react": "18.3.1",
"@types/react-datepicker": "4.19.6",
"@types/react-dom": "18.3.0",
"@types/seedrandom": "3.0.8",
"@types/zxcvbn": "4.4.4",
"@ultraviolet/themes": "workspace:*",
"@ultraviolet/ui": "workspace:*",
"@vitejs/plugin-react": "4.2.1",
"@vitest/coverage-istanbul": "1.6.0",
"@vitest/ui": "1.6.0",
"babel-loader": "9.1.3",
"babel-plugin-annotate-pure-calls": "0.4.0",
"babel-plugin-named-exports-order": "0.0.2",
Expand All @@ -163,12 +153,10 @@
"eslint-plugin-testing-library": "6.2.2",
"expect": "29.7.0",
"file-loader": "6.2.0",
"happy-dom": "14.11.0",
"husky": "9.0.11",
"identity-obj-proxy": "3.0.0",
"jest": "29.7.0",
"jest-axe": "8.0.0",
"jest-environment-jsdom": "29.7.0",
"jest-junit": "16.0.0",
"lint-staged": "15.2.2",
"postcss": "8.4.38",
"prettier": "3.2.5",
Expand All @@ -185,6 +173,9 @@
"timekeeper": "2.3.1",
"typescript": "5.4.5",
"vite": "5.2.11",
"vitest": "1.6.0",
"vitest-canvas-mock": "0.3.3",
"vitest-localstorage-mock": "0.1.2",
"zxcvbn": "4.4.2"
}
}
47 changes: 0 additions & 47 deletions packages/form/.jest/helpers.tsx

This file was deleted.

Loading

0 comments on commit 55e5bdf

Please sign in to comment.