Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: switch from jest to vitest #10412

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"extends": [
"@ownclouders",
"plugin:jest/recommended"
],
"plugins": ["jest"],
"rules": {
"jest/no-standalone-expect": "off"
}
"@ownclouders"
]
}
8 changes: 0 additions & 8 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ shared-workspace-lockfile=true
# apps
public-hoist-pattern[]=owncloud-sdk

# esm modules (so we can easily transpile them via jest config)
public-hoist-pattern[]=lodash-es
public-hoist-pattern[]=mark.js
public-hoist-pattern[]=fuse.js
public-hoist-pattern[]=filesize
public-hoist-pattern[]=layerr
public-hoist-pattern[]=webdav

# @vue/component-compiler-utils
hoist-pattern[]=sass

Expand Down
5 changes: 0 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
},
"editor.formatOnSave": true,
"eslint.format.enable": true,
"jest.autoRun": {
"watch": false,
"onStartup": true
},
"jest.jestCommandLine": "pnpm test:unit",
"npm.packageManager": "pnpm",
"typescript.format.enable": false,
"editor.quickSuggestions": {
Expand Down
2 changes: 0 additions & 2 deletions __mocks__/axios.js

This file was deleted.

8 changes: 0 additions & 8 deletions __mocks__/file.js

This file was deleted.

Empty file removed __mocks__/style.js
Empty file.
32 changes: 5 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint": "eslint vite.config.ts '{packages,tests}/**/*.{js,ts,vue}' --color",
"serve": "SERVER=true pnpm build:w",
"test:e2e:cucumber": "NODE_TLS_REJECT_UNAUTHORIZED=0 TS_NODE_PROJECT=./tests/e2e/cucumber/tsconfig.json cucumber-js --profile=e2e -f json:tests/e2e/cucumber/report/cucumber_report.json",
"test:unit": "NODE_OPTIONS=--unhandled-rejections=throw jest --config ./tests/unit/config/jest.config.ts",
"test:unit": "NODE_OPTIONS=--unhandled-rejections=throw TZ=UTC vitest --config ./tests/unit/config/vitest.config.ts",
"licenses:check": "license-checker-rseidelsohn --summary --relativeLicensePath --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages '@ownclouders/babel-preset;@ownclouders/eslint-config;@ownclouders/prettier-config;@ownclouders/tsconfig;@ownclouders/web-client;@ownclouders/web-pkg;draw-io;external;web-app-files;text-editor;preview;web-app-ocm;@ownclouders/design-system;pdf-viewer;web-app-search;admin-settings;webfinger;web-runtime'",
"licenses:csv": "license-checker-rseidelsohn --relativeLicensePath --csv --out ./third-party-licenses/third-party-licenses.csv",
"licenses:save": "license-checker-rseidelsohn --relativeLicensePath --out /dev/null --files ./third-party-licenses/third-party-licenses",
Expand Down Expand Up @@ -63,16 +63,12 @@
"@ownclouders/tsconfig": "workspace:*",
"@playwright/test": "1.39.0",
"@rollup/plugin-inject": "5.0.3",
"@types/jest": "29.5.1",
"@types/jest-axe": "3.5.9",
"@types/lodash-es": "4.17.7",
"@types/node": "16.18.30",
"@types/node-fetch": "2.6.10",
"@vitejs/plugin-vue": "4.6.2",
"@vitejs/plugin-vue": "5.0.3",
"@vue/test-utils": "v2.4.0-alpha.0",
"@vue/vue3-jest": "29.2.4",
"autoprefixer": "10.4.16",
"babel-jest": "29.5.0",
"browserslist-to-esbuild": "^1.2.0",
"browserslist-useragent-regexp": "^4.0.0",
"commander": "11.1.0",
Expand All @@ -81,15 +77,8 @@
"cucumber-html-reporter": "7.1.1",
"ejs": "3.1.9",
"eslint": "8.56.0",
"eslint-plugin-jest": "^27.6.1",
"flush-promises": "1.0.2",
"git-repo-info": "2.1.1",
"jest": "29.7.0",
"jest-axe": "8.0.0",
"jest-environment-jsdom": "29.7.0",
"jest-mock-axios": "4.7.3",
"jest-mock-extended": "3.0.5",
"jest-serializer-vue-tjw": "^3.19.0",
"join-path": "1.1.1",
"jsdom": "^20.0.2",
"license-checker-rseidelsohn": "3.3.0",
Expand All @@ -104,12 +93,14 @@
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-visualizer": "5.9.0",
"sass": "1.69.7",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"tslib": "2.5.0",
"typescript": "5.3.3",
"url-search-params-polyfill": "8.1.1",
"vite": "5.0.12",
"vitest": "1.2.1",
"vitest-mock-extended": "1.3.1",
"@vitest/coverage-v8": "1.2.1",
"vite-plugin-environment": "^1.1.3",
"vue-tsc": "1.8.10",
"vue3-gettext": "2.4.0",
Expand Down Expand Up @@ -139,19 +130,6 @@
"@uppy/utils": "https://github.com/owncloud/uppy/releases/download/v3.12.13-owncloud/uppy-utils.tgz",
"@uppy/webdav": "https://github.com/owncloud/uppy/releases/download/v3.12.13-owncloud/uppy-webdav.tgz",
"@uppy/xhr-upload": "https://github.com/owncloud/uppy/releases/download/v3.12.13-owncloud/uppy-xhr-upload.tgz"
},
"packageExtensions": {
"jest-serializer-vue-tjw": {
"dependencies": {
"@vue/compiler-sfc": "2.7.14"
}
}
},
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
},
"jestSerializer": {
"sortAttributes": true
}
}
9 changes: 2 additions & 7 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
"styleguide": "vue-styleguidist server --open --config ./config/docs.config.js",
"styleguide:build": "vue-styleguidist build --config ./config/docs.config.js",
"tokens": "node build/build-tokens.js",
"tokens:w": "onchange -i \"./src/tokens/**/*.json\" -- npm run tokens",
"test": "jest --config ./jest.conf.js --coverage",
"test:e2e": "playwright test --config ./tests/e2e/playwright.config.ts"
"tokens:w": "onchange -i \"./src/tokens/**/*.json\" -- npm run tokens"
},
"browserslist": [
"> 1%",
Expand All @@ -54,7 +52,6 @@
"@popperjs/core": "^2.11.5",
"autoprefixer": "10.4.16",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "29.5.0",
"babel-loader": "^9.0.0",
"babel-plugin-require-context-hook": "^1.0.0",
"chalk": "^4.1.2",
Expand All @@ -69,10 +66,8 @@
"fuse.js": "6.6.2",
"glob": "^10.0.0",
"html-loader": "^1.3.2",
"jest": "^29.7.0",
"jest-axe": "8.0.0",
"jest-environment-jsdom": "29.7.0",
"jest-serializer-vue-tjw": "^3.19.0",
"lodash-es": "4.17.21",
"luxon": "3.2.1",
"mini-css-extract-plugin": "^1.3.1",
"node-notifier": "^10.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`OcAvatarCount dynamically calculates font size 1`] = `<span class="oc-avatar-count" style="width: 100px; height: 100px; font-size: 40px;">+2</span>`;
exports[`OcAvatarCount > dynamically calculates font size 1`] = `"<span class="oc-avatar-count" style="width: 100px; height: 100px; font-size: 40px;">+2</span>"`;
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const items = [

describe('OcAvatars', () => {
it('displays tooltip', () => {
const OcTooltip = jest.fn()
const OcTooltip = vi.fn()
const wrapper = shallowMount(Avatars, {
props: {
items,
Expand All @@ -60,7 +60,7 @@ describe('OcAvatars', () => {
})

it('prefers avatars over links when maxDisplayed is exceeded', () => {
const OcTooltip = jest.fn()
const OcTooltip = vi.fn()
const wrapper = shallowMount(Avatars, {
props: {
items,
Expand All @@ -82,7 +82,7 @@ describe('OcAvatars', () => {
})

it('shows avatars first and links last', () => {
const OcTooltip = jest.fn()
const OcTooltip = vi.fn()
const wrapper = shallowMount(Avatars, {
props: {
items,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`OcAvatars displays tooltip 1`] = `
<span>
<span aria-hidden="true" class="oc-avatars"><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" width="30"></oc-avatar-stub><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" width="30"></oc-avatar-stub> <!--v-if--> <oc-avatar-count-stub count="3" size="30"></oc-avatar-count-stub></span>
<span class="oc-invisible-sr">List of users</span>
</span>
`;
exports[`OcAvatars > displays tooltip 1`] = `"<span><span class="oc-avatars" aria-hidden="true"><oc-avatar-stub src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" accessiblelabel="" width="30"></oc-avatar-stub><oc-avatar-stub src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" accessiblelabel="" width="30"></oc-avatar-stub> <!--v-if--> <oc-avatar-count-stub count="3" size="30"></oc-avatar-count-stub></span> <span class="oc-invisible-sr">List of users</span></span>"`;

exports[`OcAvatars prefers avatars over links when maxDisplayed is exceeded 1`] = `
<span>
<span aria-hidden="true" class="oc-avatars"><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" width="30"></oc-avatar-stub><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" width="30"></oc-avatar-stub><oc-avatar-stub accessiblelabel="" src="" username="John Richards Emperor of long names" width="30"></oc-avatar-stub> <!--v-if--> <oc-avatar-count-stub count="2" size="30"></oc-avatar-count-stub></span>
<span class="oc-invisible-sr">List of users</span>
</span>
`;
exports[`OcAvatars > prefers avatars over links when maxDisplayed is exceeded 1`] = `"<span><span class="oc-avatars" aria-hidden="true"><oc-avatar-stub src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" accessiblelabel="" width="30"></oc-avatar-stub><oc-avatar-stub src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" accessiblelabel="" width="30"></oc-avatar-stub><oc-avatar-stub src="" username="John Richards Emperor of long names" accessiblelabel="" width="30"></oc-avatar-stub> <!--v-if--> <oc-avatar-count-stub count="2" size="30"></oc-avatar-count-stub></span> <span class="oc-invisible-sr">List of users</span></span>"`;

exports[`OcAvatars shows avatars first and links last 1`] = `
<span>
<span aria-hidden="true" class="oc-avatars"><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" width="30"></oc-avatar-stub><oc-avatar-stub accessiblelabel="" src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" width="30"></oc-avatar-stub><oc-avatar-stub accessiblelabel="" src="" username="John Richards Emperor of long names" width="30"></oc-avatar-stub> <oc-avatar-link-stub accessiblelabel="" iconsize="small" name="link 0" width="30"></oc-avatar-link-stub><oc-avatar-link-stub accessiblelabel="" iconsize="small" name="link 1" width="30"></oc-avatar-link-stub> <!--v-if--></span>
<span class="oc-invisible-sr">List of users</span>
</span>
`;
exports[`OcAvatars > shows avatars first and links last 1`] = `"<span><span class="oc-avatars" aria-hidden="true"><oc-avatar-stub src="https://images.unsplash.com/photo-1610216705422-caa3fcb6d158?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Bob" accessiblelabel="" width="30"></oc-avatar-stub><oc-avatar-stub src="https://images.unsplash.com/photo-1584308972272-9e4e7685e80f?ixid=MXwxMjA3fDB8MHxzZWFyY2h8Mzh8fGZhY2V8ZW58MHwyfDB8&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=800&amp;q=60" username="Marie" accessiblelabel="" width="30"></oc-avatar-stub><oc-avatar-stub src="" username="John Richards Emperor of long names" accessiblelabel="" width="30"></oc-avatar-stub> <oc-avatar-link-stub name="link 0" accessiblelabel="" width="30" iconsize="small"></oc-avatar-link-stub><oc-avatar-link-stub name="link 1" accessiblelabel="" width="30" iconsize="small"></oc-avatar-link-stub> <!--v-if--></span> <span class="oc-invisible-sr">List of users</span></span>"`;
Loading