74 Commits

Author SHA1 Message Date
Vladimir
a3dc47b038
feat!(snapshot): make snapshots more visually pleasing (#3961) 2023-09-27 10:27:32 +02:00
Vladimir
e649d78ff6
fix: print value shape when .resolves and .rejects fails (#4137) 2023-09-18 13:25:35 +02:00
Misery Lee
5eb8561c55
fix: should remove mockPath from callstack whether success or failed (#3971)
Co-authored-by: lijifei <lijifei@bytedance.com>
2023-08-21 18:29:03 +02:00
Vladimir
b09298528b
feat!: support running tests using VM context (#3203)
Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>
2023-08-01 08:59:55 +02:00
Vladimir
c1004e1493
fix(mocker)!: don't restore mock to the original if module is mocked (#3518) 2023-06-06 19:00:24 +02:00
Dunqing
50f0700d24
fix(vite-node): circular import stuck (#3480) 2023-06-06 17:44:31 +02:00
Vladimir
03d34249ac
revert: "fix(vite-node): circular import stuck" #3418 (#3479) 2023-05-31 16:18:08 +02:00
Alessandro Di Dio
b3602bcc4d
feat(dev): add moduleDirectories option to the vitest config (#3337)
Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
2023-05-30 10:13:10 +02:00
Dunqing
632eef4037
fix(vite-node): circular import stuck (#3418) 2023-05-24 15:46:08 +02:00
Vladimir
d1afd26216
fix: don't restore methods in automocked dependencies (#3438) 2023-05-24 09:15:33 +02:00
renovate[bot]
48c4e8c68b
chore(deps): update all non-major dependencies (#3238)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
2023-05-04 08:18:01 +02:00
Vladimir
0c09a40d2b
feat!: update mock implementation to support ESM runtime, introduce "vi.hoisted" (#3258) 2023-04-27 15:04:05 +02:00
Oriol
31f835f156
docs: updated "vi.mock" documentation link (#3198) 2023-04-15 10:54:27 +02:00
renovate[bot]
0f86ff9897
chore(deps): update all non-major dependencies (#2766)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
2023-04-06 16:53:03 +02:00
Vladimir
fcd2df2c23
refactor: update errors (#2816)
* perf: bypass source map handling, when using "resolves"/"rejects"

* chore: revert snapshot improvements

* test: fix test

* chore: fix initialization

* chore: fix snapshot
2023-02-11 16:53:41 +01:00
Vladimir
a186a7e12f
fix: don't use ownKeys, when interoping a module (#2629) 2023-01-10 18:24:50 +01:00
Vladimir
6b3e36d4e9
fix: allow mocking CJS module with interoped default (#2598)
* fix: allow mocking CJS module with interoped default

* chore: cleanup

* chore: cleanup
2023-01-06 13:11:10 +01:00
Vladimir
c479d9c0d2
fix: don't hang when mocking module with circular dependency (#2572) 2022-12-28 14:52:25 +01:00
Vladimir
a431df80b3
fix: correctly automock nested interoped defaults (#2559)
* fix: correctly automock nested interoped defaults

* chore: cleanup

* chore: cleanup
2022-12-25 09:13:16 +01:00
Anthony Fu
853eeddba8
feat(mock): expose a importOriginal helper to the factory (#2551) 2022-12-22 14:26:05 +01:00
Vladimir
58ee8e9b63
feat!: rewrite how vite-node resolves id (#2463)
* feat!: rewrite how vite-node resolves id

* chore: try to fix global setup test

* fix: remove /@fs/ from filepath

* chore: cleanup

* fix: normalize id for callstack

* fix: don't append "/" before disk drive on windows

* chore: cleanup

* chore: add test that windows drive is not repeated

* fix: dirname uses \\, update windows paths tests

* refactor: rename variables

* fix: don't provide importer only for /@id/

* chore: remove null byte placeholder as part of unwrapRef

* chore: cleanup

* chore: variables renaming

* fix: don't hang on circular mock

* test: update c8 snapshot

* chore: add compatibility layer for users who don't provide resolveId

* test: fix url handling in web worker

* test: fix file tests on windows

* chore: remove unnecessary normalizations in mocker

* chore: use /@fs/ when fetching module, if possible
2022-12-16 15:32:34 +01:00
Vladimir
32cc1a66df
chore: improve error, when accessing undefined mocked key (#2388) 2022-12-05 15:30:13 +01:00
Vladimir
96d1267bcb
feat: give helpful message, when using vi.mock (#2047) 2022-09-18 11:01:13 +08:00
Vladimir
7ae53dcfcb
fix(mocker): correctly mock libraries with extension in their name (#2035) 2022-09-13 11:13:31 +03:00
Vladimir
b237e64b9a
test: fix cypress tests by deduping vue (#2036)
* test: fix cypress tests by deduping vue

* chore: add vue dependency to mocks

* chore: cleanup
2022-09-13 11:13:21 +03:00
Simon Abbott
9f887f3598
fix: automock getters and setters (#1903)
* fix: automock getters and setters

* refactor: do not mock getters/setters

Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
2022-08-30 18:48:57 +03:00
Lioness100
f13e54f096
chore: fix typos (#1857)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
2022-08-15 18:38:15 +00:00
Anthony Fu
b70593955f
chore: update deps (#1853) 2022-08-15 15:13:37 +08:00
jereklas
8eddd5a380
fix: handle undefined returns of module mocks, and update migration docs (#1763) (#1830)
* handle undefined returns of module mocks, and update migration docs

* correct docs
2022-08-11 09:18:43 +03:00
jereklas
7574759127
fix: add error message when mock is missing export (#1819) 2022-08-08 18:10:59 +03:00
Anthony Fu
49c67d2573
fix(vite-node): self circular reference (#1609) 2022-07-07 16:39:20 +08:00
Vladimir
235b9502f9
fix: can mock files with space in path (#1457)
* fix: can mock files with space in path

* test: testing files with spaces
2022-06-10 10:10:55 +03:00
Anthony Fu
51459c9ce8 chore: update deps 2022-05-27 13:26:48 +08:00
Anthony Fu
4a046df559 chore: lint 2022-05-14 16:36:12 +08:00
Vladimir
c491fb448a
fix: can mock non-existent paths and virtual modules via __mocks__ (#1298) 2022-05-13 13:47:30 +00:00
Vladimir
7459ff8a46
fix: clear mock from callstack, if mocked with factory (#1276)
* fix: clear mock from callstack, if mocked with factory

* test: fix test for zustand
2022-05-09 11:38:11 +03:00
Anthony Fu
29c8cee5c4 chore: update deps 2022-05-08 04:51:58 +08:00
Vladimir
110788a793
fix: resolve id before loading from vite (#1204)
* fix: resolve id before loading from vite

* fix: allow import actual modules inside a factory of __mocks__ file

* test: fix custom reporters test

* fix: invalidate mocks

* chore: fix compatability with node 14

* chore: fix callstack position

* chore: remove collect from worker.ts since entry doesn't export that function

* chore: fix pnpm-lock

* chore: slice "mock" from stacktrace

* chore: fix checking callstack for a function mock

* chore: add description to factory mock

* test: add test for importing itself inside __mocks__ folder
2022-05-08 04:41:05 +08:00
Anthony Fu
317766f70f chore: apply lint 2022-05-02 23:12:20 +08:00
Anthony Fu
f99e043ab4 chore: update lock 2022-04-25 20:14:27 +08:00
Anthony Fu
713c870a55 chore: lint 2022-04-25 19:44:30 +08:00
Anthony Fu
4b785138e1 chore: update deps 2022-04-25 19:43:45 +08:00
renovate[bot]
4d1e0a0ed1
fix(deps): update all non-major dependencies (#1159)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-21 22:25:34 +08:00
renovate[bot]
40c26ed3b8
chore(deps): update all non-major dependencies (#1137)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-13 07:53:43 +08:00
eleith
06faf8ad49
fix: make automocking aware of symbol indexed methods (#1119)
Co-authored-by: eleith <online-github@eleith.com>
2022-04-08 02:10:19 +08:00
renovate[bot]
16684b2ae2
chore(deps): update all non-major dependencies (#1094)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-04 10:56:54 +08:00
Vladimir
885b25d4f2
fix: automocking prototype fix (#1083) 2022-04-03 15:55:02 +08:00
Anthony Fu
43f681914a chore: update deps 2022-04-02 00:30:52 +08:00
renovate[bot]
ffa0228034
chore(deps): update all non-major dependencies (#1042)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-28 10:13:38 +08:00
renovate[bot]
a1cab8ee30
chore(deps): update all non-major dependencies (#995)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-21 18:50:28 +08:00