24 Commits

Author SHA1 Message Date
Vladimir
6c1a26a6a3
fix: mock css files imported with "require" (#2679)
This is usually happens inside UI libraries
2023-01-16 13:10:23 +01:00
Vladimir
084e929c8e
fix!: correctly interop nested default for external and inlined modules (#2512)
* fix: correctly interop nested default for external and inlined modules, if environment is not node

* chore: cleanup

* chore: cleanup

* test: update default interop test

* chore: update module interop tests

* fix: add environment to enzym example

* chore: update tests

* test: don't run module tests without threads, because we don't clear ESM cache

* chore: correctly reset current test environment
2022-12-16 15:33:42 +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
4131a52e1e
feat!: improve interchangeability with cjs (#1944) 2022-09-04 10:54:33 +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
Simon Abbott
285ac7c24e
fix: allow referring to first seen value while automocking (#1879) 2022-08-19 08:27:18 +03:00
Simon Abbott
b1cd7e71e0
fix: gracefully handle unsettable keys during automocking (#1786)
Sometimes while automocking we will encounter a property that, for some
unknown reason, throws an error when you try to define it. Unfortunately
I can't figure out _why_ it errors, so instead I have opted to quietly
skip these unsettable properties. If that becomes a problem in the
future this can be revisited, but I don't forsee it being an issue since
these keys are mostly deeply internal prototype stuff that 99.999% of
people don't even know exists, let alone want to mock. Plus, if you
_really_ need to have this behavior you can always use `__mocks__` or
just shim it inline yourself.
2022-08-05 18:52:13 +03:00
Vladimir
7c2138f2b0
feat: add alias option (#1634)
* chore: fix typeof check in error

* feat: add alias option

* Update test/core/vitest.config.ts
2022-07-19 17:44:21 +03:00
Simon Abbott
4aeeee092e
fix: mock properties of classes/functions (fix #1523) (#1648) 2022-07-16 23:08:10 +08:00
Yuyao Nie
b802d5e8c5
fix: replace root when resolving dependency (#1310) 2022-05-20 18:03:26 +03:00
Yuyao Nie
cd4bed5ad3
fix: make exports prop of proxy point to exports object (#1260) 2022-05-09 21:07:38 +08:00
Carlos Rodrigues
4956713a77
fix: self exported module call stack error (#1221)
* fix: self exported module call stack error

* remove warning
2022-05-01 16:34:19 +00:00
Kalven Schraut
7b983445a8
fix(vite-node): normalize relative paths to be from current working directory (#952) 2022-03-17 06:39:38 +08:00
Vladimir
5f007889bb
feat: allow changing import.meta.env (#714) 2022-02-10 00:52:55 +08:00
Vladimir Sheremet
dda62d0af8 feat: vi.mock can be used inside setupFiles to automock libraries 2022-01-17 14:58:58 +03:00
Vladimir
fdfffaebd0
fix: mock node builtins (#454) 2022-01-06 23:29:33 +08:00
Vladimir Sheremet
9c119ad1e0 fix: vi.mock works with node internals 2022-01-06 09:32:22 +03:00
Vladimir
6e39a1d7d8
feat: jest's mock compatible implementation (#146)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Co-authored-by: SaulMirone <mirone@SaulMirones-MacBook-Pro.local>
Co-authored-by: Christian Hamburger Grøngaard <christianhg@gmail.com>
Co-authored-by: Narcis B <leonardssh22@gmail.com>
Co-authored-by: patak <matias.capeletto@gmail.com>
Co-authored-by: Sachin Raja <sachinraja2349@gmail.com>
Co-authored-by: Jake Ginnivan <jake@ginnivan.net>
Co-authored-by: Mirone <Saul-Mirone@outlook.com>
2021-12-21 19:14:14 +08:00
Anthony Fu
c9f688f81d chore: revert time out change 2021-12-12 09:20:39 +08:00
Anthony Fu
e064425081 fix(watcher): avoid racing 2021-12-12 09:19:39 +08:00
Anthony Fu
ebcb529ea0 feat: format snapshot summary 2021-12-11 03:09:55 +08:00
Anthony Fu
dbc7062209 chore: clear 2021-12-10 13:54:40 +08:00
Anthony Fu
7a70ffaca9 feat: source-map support, thanks @Akryum 2021-12-10 13:53:17 +08:00
Anthony Fu
0bc512400b feat: resolve circular dependencies 2021-12-08 19:37:26 +08:00