diff --git a/examples/mocks/package.json b/examples/mocks/package.json index 8888e178dfb5..b9ce881f5a92 100644 --- a/examples/mocks/package.json +++ b/examples/mocks/package.json @@ -14,11 +14,11 @@ "dependencies": { "@vueuse/integrations": "^7.6.2", "axios": "^0.26.0", - "tinyspy": "^0.2.10" + "tinyspy": "^0.3.0" }, "devDependencies": { "@vitest/ui": "latest", "vite": "latest", "vitest": "latest" } -} +} \ No newline at end of file diff --git a/packages/vitest/package.json b/packages/vitest/package.json index 3f6510018bc4..bc4e7a82871e 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -60,7 +60,7 @@ "chai": "^4.3.6", "local-pkg": "^0.4.1", "tinypool": "^0.1.2", - "tinyspy": "^0.2.10", + "tinyspy": "^0.3.0", "vite": "^2.8.2" }, "devDependencies": { @@ -127,4 +127,4 @@ "engines": { "node": ">=14.14.0" } -} +} \ No newline at end of file diff --git a/packages/vitest/src/integrations/jest-mock.ts b/packages/vitest/src/integrations/jest-mock.ts index 87dda587f1ad..6ec15bdb8dd4 100644 --- a/packages/vitest/src/integrations/jest-mock.ts +++ b/packages/vitest/src/integrations/jest-mock.ts @@ -103,8 +103,8 @@ export const spies = new Set() export function isMockFunction(fn: any): fn is EnhancedSpy { return typeof fn === 'function' - && '__isSpy' in fn - && fn.__isSpy + && '_isMockFunction' in fn + && fn._isMockFunction } export function spyOn>>( diff --git a/packages/vitest/src/node/mocker.ts b/packages/vitest/src/node/mocker.ts index 3a20d0ec18f3..409137843e51 100644 --- a/packages/vitest/src/node/mocker.ts +++ b/packages/vitest/src/node/mocker.ts @@ -186,7 +186,7 @@ export class VitestMocker { newObj[k] = this.mockObject(obj[k]) const type = getObjectType(obj[k]) - if (type.includes('Function') && !obj[k].__isSpy) { + if (type.includes('Function') && !obj[k]._isMockFunction) { this.spy.spyOn(newObj, k).mockImplementation(() => {}) Object.defineProperty(newObj[k], 'length', { value: 0 }) // tinyspy retains length, but jest doesnt } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c25962a4b7c..b6e29db93e22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,7 +111,7 @@ importers: lit: 2.1.3 devDependencies: '@vitest/ui': link:../../packages/ui - happy-dom: 2.31.1 + happy-dom: 2.38.0 vite: 2.8.1 vitest: link:../../packages/vitest @@ -120,13 +120,13 @@ importers: '@vitest/ui': latest '@vueuse/integrations': ^7.6.2 axios: ^0.26.0 - tinyspy: ^0.2.10 + tinyspy: ^0.3.0 vite: ^2.8.1 vitest: latest dependencies: '@vueuse/integrations': 7.6.2_axios@0.26.0+vue@3.2.26 axios: 0.26.0 - tinyspy: 0.2.10 + tinyspy: 0.3.0 devDependencies: '@vitest/ui': link:../../packages/ui vite: 2.8.1 @@ -400,7 +400,7 @@ importers: devDependencies: '@vitejs/plugin-vue': 2.2.0_vite@2.8.1+vue@3.2.26 '@vue/test-utils': 2.0.0-rc.18_vue@3.2.26 - happy-dom: 2.31.1 + happy-dom: 2.38.0 unplugin-auto-import: 0.5.11_c9f0c919646870b330eb2f68bb613c23 unplugin-vue-components: 0.17.18_2b5a3da0f36de7deafc8d4f2e66b93cf vitest: link:../../packages/vitest @@ -417,7 +417,7 @@ importers: devDependencies: '@vitejs/plugin-vue': 2.2.0_vite@2.8.1+vue@3.2.26 '@vue/test-utils': 2.0.0-rc.18_vue@3.2.26 - happy-dom: 2.31.1 + happy-dom: 2.38.0 vitest: link:../../packages/vitest examples/vue-jsx: @@ -433,7 +433,7 @@ importers: '@vitejs/plugin-vue': 2.2.0_vite@2.8.1+vue@3.2.26 '@vitejs/plugin-vue-jsx': 1.3.7 '@vue/test-utils': 2.0.0-rc.18_vue@3.2.26 - happy-dom: 2.31.1 + happy-dom: 2.38.0 vite: 2.8.1 vitest: link:../../packages/vitest vue: 3.2.26 @@ -549,7 +549,7 @@ importers: source-map-js: ^1.0.2 strip-ansi: ^7.0.1 tinypool: ^0.1.2 - tinyspy: ^0.2.10 + tinyspy: ^0.3.0 typescript: ^4.5.5 vite: ^2.8.1 vite-node: workspace:* @@ -560,7 +560,7 @@ importers: chai: 4.3.6 local-pkg: 0.4.1 tinypool: 0.1.2 - tinyspy: 0.2.10 + tinyspy: 0.3.0 vite: 2.8.1 devDependencies: '@antfu/install-pkg': 0.1.0 @@ -2423,6 +2423,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.13.9 + dev: true /@babel/runtime/7.17.2: resolution: {integrity: sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==} @@ -2590,7 +2591,7 @@ packages: dependencies: '@babel/helper-module-imports': 7.16.0 '@babel/plugin-syntax-jsx': 7.16.0 - '@babel/runtime': 7.16.7 + '@babel/runtime': 7.17.2 '@emotion/hash': 0.8.0 '@emotion/memoize': 0.7.5 '@emotion/serialize': 1.0.2 @@ -3047,7 +3048,7 @@ packages: dependencies: '@babel/runtime': 7.17.2 '@emotion/is-prop-valid': 1.1.1 - '@mui/utils': 5.4.1_react@17.0.2 + '@mui/utils': 5.4.2_react@17.0.2 '@popperjs/core': 2.11.0 clsx: 1.1.1 prop-types: 15.7.2 @@ -3159,22 +3160,6 @@ packages: react-transition-group: 4.4.2_react-dom@17.0.2+react@17.0.2 dev: false - /@mui/private-theming/5.4.1_react@17.0.2: - resolution: {integrity: sha512-Xbc4MXFZxv0A3hoc4TSDBhzjhstppKfc+gQcTMqqBZQP7KjnmxF+wO7rEPQuYRBihjCqQBdrHIGMLsKWrhkZkQ==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@types/react': ^16.8.6 || ^17.0.0 - react: ^17.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.17.2 - '@mui/utils': 5.4.1_react@17.0.2 - prop-types: 15.7.2 - react: 17.0.2 - dev: false - /@mui/private-theming/5.4.2_react@17.0.2: resolution: {integrity: sha512-mlPDYYko4wIcwXjCPEmOWbNTT4DZ6h9YHdnRtQPnWM28+TRUHEo7SbydnnmVDQLRXUfaH4Y6XtEHIfBNPE/SLg==} engines: {node: '>=12.0.0'} @@ -3191,27 +3176,6 @@ packages: react: 17.0.2 dev: false - /@mui/styled-engine/5.4.1_922a85da57e3646a57465b7970b0de85: - resolution: {integrity: sha512-CFLNJkopRoAuShkgUZOTBVxdTlKu4w6L4kOwPi4r3QB2XXS6O5kyLHSsg9huUbtOYk5Dv5UZyUSc5pw4J7ezdg==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@emotion/react': ^11.4.1 - '@emotion/styled': ^11.3.0 - react: ^17.0.0 - peerDependenciesMeta: - '@emotion/react': - optional: true - '@emotion/styled': - optional: true - dependencies: - '@babel/runtime': 7.17.2 - '@emotion/cache': 11.7.1 - '@emotion/react': 11.7.1_react@17.0.2 - '@emotion/styled': 11.6.0_79c1490562c3c65ef55eb132a37e39b4 - prop-types: 15.7.2 - react: 17.0.2 - dev: false - /@mui/styled-engine/5.4.2_922a85da57e3646a57465b7970b0de85: resolution: {integrity: sha512-tz9p3aRtzXHKAg7x3BgP0hVQEoGKaxNCFxsJ+d/iqEHYvywWFSs6oxqYAvDHIRpvMlUZyPNoTrkcNnbdMmH/ng==} engines: {node: '>=12.0.0'} @@ -3252,10 +3216,10 @@ packages: '@babel/runtime': 7.17.2 '@emotion/react': 11.7.1_react@17.0.2 '@emotion/styled': 11.6.0_79c1490562c3c65ef55eb132a37e39b4 - '@mui/private-theming': 5.4.1_react@17.0.2 - '@mui/styled-engine': 5.4.1_922a85da57e3646a57465b7970b0de85 - '@mui/types': 7.1.1 - '@mui/utils': 5.4.1_react@17.0.2 + '@mui/private-theming': 5.4.2_react@17.0.2 + '@mui/styled-engine': 5.4.2_922a85da57e3646a57465b7970b0de85 + '@mui/types': 7.1.2 + '@mui/utils': 5.4.2_react@17.0.2 clsx: 1.1.1 csstype: 3.0.10 prop-types: 15.7.2 @@ -5381,7 +5345,7 @@ packages: engines: {node: '>=12'} dependencies: '@babel/code-frame': 7.16.0 - '@babel/runtime': 7.16.3 + '@babel/runtime': 7.17.2 '@types/aria-query': 4.2.2 aria-query: 5.0.0 chalk: 4.1.2 @@ -5509,7 +5473,7 @@ packages: /@types/concat-stream/1.6.1: resolution: {integrity: sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==} dependencies: - '@types/node': 17.0.14 + '@types/node': 17.0.17 dev: true /@types/cookie/0.4.1: @@ -5565,7 +5529,7 @@ packages: /@types/form-data/0.0.33: resolution: {integrity: sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=} dependencies: - '@types/node': 17.0.14 + '@types/node': 17.0.17 dev: true /@types/fs-extra/9.0.13: @@ -7235,7 +7199,7 @@ packages: /babel-plugin-macros/2.8.0: resolution: {integrity: sha512-SEP5kJpfGYqYKpBrj5XU3ahw5p5GOHJ0U5ssOSQ/WBVdwkD2Dzlce95exQTs3jOVWPPKLBN2rlEWkCK7dSmLvg==} dependencies: - '@babel/runtime': 7.16.7 + '@babel/runtime': 7.17.2 cosmiconfig: 6.0.0 resolve: 1.20.0 @@ -11207,6 +11171,20 @@ packages: - encoding dev: true + /happy-dom/2.38.0: + resolution: {integrity: sha512-xQaalTijrX2shAZoi9Z1iBKArHtU2KVrRKiYXZELPU4Rnzv0UMggw6ZaLM8eR6k2XPDDwuppV7PZktNhyNM8og==} + dependencies: + css.escape: 1.5.1 + he: 1.2.0 + node-fetch: 2.6.7 + sync-request: 6.1.0 + webidl-conversions: 7.0.0 + whatwg-encoding: 1.0.5 + whatwg-mimetype: 2.3.0 + transitivePeerDependencies: + - encoding + dev: true + /has-bigints/1.0.1: resolution: {integrity: sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==} dev: true @@ -12305,7 +12283,7 @@ packages: whatwg-encoding: 2.0.0 whatwg-mimetype: 3.0.0 whatwg-url: 10.0.0 - ws: 8.4.2 + ws: 8.5.0 xml-name-validator: 4.0.0 transitivePeerDependencies: - bufferutil @@ -16250,6 +16228,12 @@ packages: /tinyspy/0.2.10: resolution: {integrity: sha512-Qij6rGWCDjWIejxCXXVi6bNgvrYBp3PbqC4cBP/0fD6WHDOHCw09Zd13CsxrDqSR5PFq01WeqDws8t5lz5sH0A==} engines: {node: '>=14.0.0'} + dev: true + + /tinyspy/0.3.0: + resolution: {integrity: sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==} + engines: {node: '>=14.0.0'} + dev: false /tmp/0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} @@ -17497,19 +17481,6 @@ packages: optional: true dev: true - /ws/8.4.2: - resolution: {integrity: sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true - /ws/8.5.0: resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} engines: {node: '>=10.0.0'}