vitest 0.24.5 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE.md +286 -57
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +17 -10
  4. package/dist/{chunk-api-setup.629f8133.js → chunk-api-setup.a13c5f9d.js} +38 -19
  5. package/dist/{chunk-install-pkg.22707ee4.js → chunk-install-pkg.55bfe508.js} +4 -5
  6. package/dist/{chunk-integrations-coverage.cca09977.js → chunk-integrations-coverage.befed097.js} +57 -1
  7. package/dist/chunk-integrations-globals.391b3839.js +25 -0
  8. package/dist/{chunk-node-git.82174cfe.js → chunk-node-git.af5c9d73.js} +5 -6
  9. package/dist/{chunk-runtime-chain.37ec5d73.js → chunk-runtime-chain.3b531731.js} +27 -23
  10. package/dist/{chunk-runtime-error.17751c39.js → chunk-runtime-error.3cc15c6f.js} +9 -2
  11. package/dist/{chunk-runtime-mocker.41b92ec9.js → chunk-runtime-mocker.a5d87666.js} +4 -4
  12. package/dist/{chunk-runtime-rpc.b418c0ab.js → chunk-runtime-rpc.4a2d45ab.js} +2 -2
  13. package/dist/chunk-runtime-setup.f644ac4c.js +1350 -0
  14. package/dist/{chunk-runtime-hooks.d748b085.js → chunk-runtime-test-state.31ce8643.js} +106 -6
  15. package/dist/{chunk-mock-date.030959d3.js → chunk-typecheck-constants.410fa7b2.js} +23 -4
  16. package/dist/{chunk-utils-env.b1281522.js → chunk-utils-env.7fe285cc.js} +2 -0
  17. package/dist/chunk-utils-source-map.1a66263d.js +90 -0
  18. package/dist/{chunk-utils-timers.8fca243e.js → chunk-utils-timers.d1fcc6bb.js} +86 -79
  19. package/dist/{chunk-vite-node-client.3868b3ba.js → chunk-vite-node-client.13ea0a59.js} +25 -5
  20. package/dist/{chunk-vite-node-externalize.d9033432.js → chunk-vite-node-externalize.01d0d22c.js} +821 -92
  21. package/dist/chunk-vite-node-utils.b89230f3.js +1400 -0
  22. package/dist/cli-wrapper.js +5 -6
  23. package/dist/cli.js +27 -13
  24. package/dist/config.cjs +6 -1
  25. package/dist/config.d.ts +6 -1
  26. package/dist/config.js +6 -1
  27. package/dist/entry.js +11 -10
  28. package/dist/environments.d.ts +1 -1
  29. package/dist/index-b68b3c09.d.ts +256 -0
  30. package/dist/index.d.ts +4 -4
  31. package/dist/index.js +13 -7
  32. package/dist/loader.js +4 -3
  33. package/dist/node.d.ts +2 -2
  34. package/dist/node.js +18 -11
  35. package/dist/suite.js +6 -6
  36. package/dist/{global-58e8e951.d.ts → types-b3ff5eea.d.ts} +215 -18
  37. package/dist/{vendor-index.cc8d244b.js → vendor-index.16d769d7.js} +1 -2
  38. package/dist/{vendor-index.12d51d29.js → vendor-index.22806ffb.js} +279 -7
  39. package/dist/{vendor-index.9c919048.js → vendor-index.808a85a6.js} +0 -0
  40. package/dist/worker.js +9 -8
  41. package/globals.d.ts +2 -0
  42. package/package.json +13 -9
  43. package/dist/chunk-integrations-globals.32ef80c3.js +0 -25
  44. package/dist/chunk-runtime-setup.ab6b6274.js +0 -676
  45. package/dist/chunk-utils-source-map.663e2952.js +0 -3429
  46. package/dist/chunk-vite-node-utils.2144000e.js +0 -6946
  47. package/dist/index-220c1d70.d.ts +0 -117
  48. package/dist/vendor-index.1a291e86.js +0 -275
@@ -2,6 +2,8 @@ import childProcess from 'child_process';
2
2
  import path$3 from 'path';
3
3
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
4
4
  import fs$1 from 'fs';
5
+ import assert$1 from 'assert';
6
+ import require$$2 from 'events';
5
7
  import require$$0$1 from 'buffer';
6
8
  import require$$0 from 'stream';
7
9
  import util from 'util';
@@ -454,7 +456,7 @@ const resolveCommand = resolveCommand_1;
454
456
  const escape = _escape;
455
457
  const readShebang = readShebang_1;
456
458
 
457
- const isWin$1 = process.platform === 'win32';
459
+ const isWin$2 = process.platform === 'win32';
458
460
  const isExecutableRegExp = /\.(?:com|exe)$/i;
459
461
  const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
460
462
 
@@ -474,7 +476,7 @@ function detectShebang(parsed) {
474
476
  }
475
477
 
476
478
  function parseNonShell(parsed) {
477
- if (!isWin$1) {
479
+ if (!isWin$2) {
478
480
  return parsed;
479
481
  }
480
482
 
@@ -539,7 +541,7 @@ function parse$1(command, args, options) {
539
541
 
540
542
  var parse_1 = parse$1;
541
543
 
542
- const isWin = process.platform === 'win32';
544
+ const isWin$1 = process.platform === 'win32';
543
545
 
544
546
  function notFoundError(original, syscall) {
545
547
  return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
@@ -552,7 +554,7 @@ function notFoundError(original, syscall) {
552
554
  }
553
555
 
554
556
  function hookChildProcess(cp, parsed) {
555
- if (!isWin) {
557
+ if (!isWin$1) {
556
558
  return;
557
559
  }
558
560
 
@@ -575,7 +577,7 @@ function hookChildProcess(cp, parsed) {
575
577
  }
576
578
 
577
579
  function verifyENOENT(status, parsed) {
578
- if (isWin && status === 1 && !parsed.file) {
580
+ if (isWin$1 && status === 1 && !parsed.file) {
579
581
  return notFoundError(parsed.original, 'spawn');
580
582
  }
581
583
 
@@ -583,7 +585,7 @@ function verifyENOENT(status, parsed) {
583
585
  }
584
586
 
585
587
  function verifyENOENTSync(status, parsed) {
586
- if (isWin && status === 1 && !parsed.file) {
588
+ if (isWin$1 && status === 1 && !parsed.file) {
587
589
  return notFoundError(parsed.original, 'spawnSync');
588
590
  }
589
591
 
@@ -635,6 +637,276 @@ crossSpawn.exports.sync = spawnSync;
635
637
  crossSpawn.exports._parse = parse;
636
638
  crossSpawn.exports._enoent = enoent;
637
639
 
640
+ var signalExit = {exports: {}};
641
+
642
+ var signals$1 = {exports: {}};
643
+
644
+ var hasRequiredSignals;
645
+
646
+ function requireSignals () {
647
+ if (hasRequiredSignals) return signals$1.exports;
648
+ hasRequiredSignals = 1;
649
+ (function (module) {
650
+ // This is not the set of all possible signals.
651
+ //
652
+ // It IS, however, the set of all signals that trigger
653
+ // an exit on either Linux or BSD systems. Linux is a
654
+ // superset of the signal names supported on BSD, and
655
+ // the unknown signals just fail to register, so we can
656
+ // catch that easily enough.
657
+ //
658
+ // Don't bother with SIGKILL. It's uncatchable, which
659
+ // means that we can't fire any callbacks anyway.
660
+ //
661
+ // If a user does happen to register a handler on a non-
662
+ // fatal signal like SIGWINCH or something, and then
663
+ // exit, it'll end up firing `process.emit('exit')`, so
664
+ // the handler will be fired anyway.
665
+ //
666
+ // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
667
+ // artificially, inherently leave the process in a
668
+ // state from which it is not safe to try and enter JS
669
+ // listeners.
670
+ module.exports = [
671
+ 'SIGABRT',
672
+ 'SIGALRM',
673
+ 'SIGHUP',
674
+ 'SIGINT',
675
+ 'SIGTERM'
676
+ ];
677
+
678
+ if (process.platform !== 'win32') {
679
+ module.exports.push(
680
+ 'SIGVTALRM',
681
+ 'SIGXCPU',
682
+ 'SIGXFSZ',
683
+ 'SIGUSR2',
684
+ 'SIGTRAP',
685
+ 'SIGSYS',
686
+ 'SIGQUIT',
687
+ 'SIGIOT'
688
+ // should detect profiler and enable/disable accordingly.
689
+ // see #21
690
+ // 'SIGPROF'
691
+ );
692
+ }
693
+
694
+ if (process.platform === 'linux') {
695
+ module.exports.push(
696
+ 'SIGIO',
697
+ 'SIGPOLL',
698
+ 'SIGPWR',
699
+ 'SIGSTKFLT',
700
+ 'SIGUNUSED'
701
+ );
702
+ }
703
+ } (signals$1));
704
+ return signals$1.exports;
705
+ }
706
+
707
+ // Note: since nyc uses this module to output coverage, any lines
708
+ // that are in the direct sync flow of nyc's outputCoverage are
709
+ // ignored, since we can never get coverage for them.
710
+ // grab a reference to node's real process object right away
711
+ var process$1 = commonjsGlobal.process;
712
+
713
+ const processOk = function (process) {
714
+ return process &&
715
+ typeof process === 'object' &&
716
+ typeof process.removeListener === 'function' &&
717
+ typeof process.emit === 'function' &&
718
+ typeof process.reallyExit === 'function' &&
719
+ typeof process.listeners === 'function' &&
720
+ typeof process.kill === 'function' &&
721
+ typeof process.pid === 'number' &&
722
+ typeof process.on === 'function'
723
+ };
724
+
725
+ // some kind of non-node environment, just no-op
726
+ /* istanbul ignore if */
727
+ if (!processOk(process$1)) {
728
+ signalExit.exports = function () {
729
+ return function () {}
730
+ };
731
+ } else {
732
+ var assert = assert$1;
733
+ var signals = requireSignals();
734
+ var isWin = /^win/i.test(process$1.platform);
735
+
736
+ var EE = require$$2;
737
+ /* istanbul ignore if */
738
+ if (typeof EE !== 'function') {
739
+ EE = EE.EventEmitter;
740
+ }
741
+
742
+ var emitter;
743
+ if (process$1.__signal_exit_emitter__) {
744
+ emitter = process$1.__signal_exit_emitter__;
745
+ } else {
746
+ emitter = process$1.__signal_exit_emitter__ = new EE();
747
+ emitter.count = 0;
748
+ emitter.emitted = {};
749
+ }
750
+
751
+ // Because this emitter is a global, we have to check to see if a
752
+ // previous version of this library failed to enable infinite listeners.
753
+ // I know what you're about to say. But literally everything about
754
+ // signal-exit is a compromise with evil. Get used to it.
755
+ if (!emitter.infinite) {
756
+ emitter.setMaxListeners(Infinity);
757
+ emitter.infinite = true;
758
+ }
759
+
760
+ signalExit.exports = function (cb, opts) {
761
+ /* istanbul ignore if */
762
+ if (!processOk(commonjsGlobal.process)) {
763
+ return function () {}
764
+ }
765
+ assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
766
+
767
+ if (loaded === false) {
768
+ load();
769
+ }
770
+
771
+ var ev = 'exit';
772
+ if (opts && opts.alwaysLast) {
773
+ ev = 'afterexit';
774
+ }
775
+
776
+ var remove = function () {
777
+ emitter.removeListener(ev, cb);
778
+ if (emitter.listeners('exit').length === 0 &&
779
+ emitter.listeners('afterexit').length === 0) {
780
+ unload();
781
+ }
782
+ };
783
+ emitter.on(ev, cb);
784
+
785
+ return remove
786
+ };
787
+
788
+ var unload = function unload () {
789
+ if (!loaded || !processOk(commonjsGlobal.process)) {
790
+ return
791
+ }
792
+ loaded = false;
793
+
794
+ signals.forEach(function (sig) {
795
+ try {
796
+ process$1.removeListener(sig, sigListeners[sig]);
797
+ } catch (er) {}
798
+ });
799
+ process$1.emit = originalProcessEmit;
800
+ process$1.reallyExit = originalProcessReallyExit;
801
+ emitter.count -= 1;
802
+ };
803
+ signalExit.exports.unload = unload;
804
+
805
+ var emit = function emit (event, code, signal) {
806
+ /* istanbul ignore if */
807
+ if (emitter.emitted[event]) {
808
+ return
809
+ }
810
+ emitter.emitted[event] = true;
811
+ emitter.emit(event, code, signal);
812
+ };
813
+
814
+ // { <signal>: <listener fn>, ... }
815
+ var sigListeners = {};
816
+ signals.forEach(function (sig) {
817
+ sigListeners[sig] = function listener () {
818
+ /* istanbul ignore if */
819
+ if (!processOk(commonjsGlobal.process)) {
820
+ return
821
+ }
822
+ // If there are no other listeners, an exit is coming!
823
+ // Simplest way: remove us and then re-send the signal.
824
+ // We know that this will kill the process, so we can
825
+ // safely emit now.
826
+ var listeners = process$1.listeners(sig);
827
+ if (listeners.length === emitter.count) {
828
+ unload();
829
+ emit('exit', null, sig);
830
+ /* istanbul ignore next */
831
+ emit('afterexit', null, sig);
832
+ /* istanbul ignore next */
833
+ if (isWin && sig === 'SIGHUP') {
834
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
835
+ // so use a supported signal instead
836
+ sig = 'SIGINT';
837
+ }
838
+ /* istanbul ignore next */
839
+ process$1.kill(process$1.pid, sig);
840
+ }
841
+ };
842
+ });
843
+
844
+ signalExit.exports.signals = function () {
845
+ return signals
846
+ };
847
+
848
+ var loaded = false;
849
+
850
+ var load = function load () {
851
+ if (loaded || !processOk(commonjsGlobal.process)) {
852
+ return
853
+ }
854
+ loaded = true;
855
+
856
+ // This is the number of onSignalExit's that are in play.
857
+ // It's important so that we can count the correct number of
858
+ // listeners on signals, and don't wait for the other one to
859
+ // handle it instead of us.
860
+ emitter.count += 1;
861
+
862
+ signals = signals.filter(function (sig) {
863
+ try {
864
+ process$1.on(sig, sigListeners[sig]);
865
+ return true
866
+ } catch (er) {
867
+ return false
868
+ }
869
+ });
870
+
871
+ process$1.emit = processEmit;
872
+ process$1.reallyExit = processReallyExit;
873
+ };
874
+ signalExit.exports.load = load;
875
+
876
+ var originalProcessReallyExit = process$1.reallyExit;
877
+ var processReallyExit = function processReallyExit (code) {
878
+ /* istanbul ignore if */
879
+ if (!processOk(commonjsGlobal.process)) {
880
+ return
881
+ }
882
+ process$1.exitCode = code || /* istanbul ignore next */ 0;
883
+ emit('exit', process$1.exitCode, null);
884
+ /* istanbul ignore next */
885
+ emit('afterexit', process$1.exitCode, null);
886
+ /* istanbul ignore next */
887
+ originalProcessReallyExit.call(process$1, process$1.exitCode);
888
+ };
889
+
890
+ var originalProcessEmit = process$1.emit;
891
+ var processEmit = function processEmit (ev, arg) {
892
+ if (ev === 'exit' && processOk(commonjsGlobal.process)) {
893
+ /* istanbul ignore else */
894
+ if (arg !== undefined) {
895
+ process$1.exitCode = arg;
896
+ }
897
+ var ret = originalProcessEmit.apply(this, arguments);
898
+ /* istanbul ignore next */
899
+ emit('exit', process$1.exitCode, null);
900
+ /* istanbul ignore next */
901
+ emit('afterexit', process$1.exitCode, null);
902
+ /* istanbul ignore next */
903
+ return ret
904
+ } else {
905
+ return originalProcessEmit.apply(this, arguments)
906
+ }
907
+ };
908
+ }
909
+
638
910
  var getStream$1 = {exports: {}};
639
911
 
640
912
  const {PassThrough: PassThroughStream} = require$$0;
@@ -790,4 +1062,4 @@ var mergeStream = function (/*streams...*/) {
790
1062
  }
791
1063
  };
792
1064
 
793
- export { crossSpawn as c, getStream$1 as g, mergeStream as m, pathKey$1 as p };
1065
+ export { crossSpawn as c, getStream$1 as g, mergeStream as m, pathKey$1 as p, signalExit as s };
package/dist/worker.js CHANGED
@@ -1,23 +1,24 @@
1
- import { b as resolve, e as distDir } from './chunk-utils-env.b1281522.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.3868b3ba.js';
1
+ import { b as resolve, e as distDir } from './chunk-utils-env.7fe285cc.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.13ea0a59.js';
3
3
  import { workerId } from 'tinypool';
4
- import { g as getWorkerState } from './chunk-mock-date.030959d3.js';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.41b92ec9.js';
6
- import { r as rpc } from './chunk-runtime-rpc.b418c0ab.js';
7
- import { p as processError } from './chunk-runtime-error.17751c39.js';
4
+ import { g as getWorkerState } from './chunk-typecheck-constants.410fa7b2.js';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.a5d87666.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.4a2d45ab.js';
7
+ import { p as processError } from './chunk-runtime-error.3cc15c6f.js';
8
8
  import 'tty';
9
9
  import 'url';
10
10
  import 'path';
11
11
  import 'module';
12
12
  import 'vm';
13
- import './chunk-vite-node-utils.2144000e.js';
13
+ import './chunk-vite-node-utils.b89230f3.js';
14
14
  import 'fs';
15
+ import 'acorn';
15
16
  import 'assert';
16
17
  import 'util';
17
18
  import 'debug';
18
19
  import 'local-pkg';
19
20
  import 'vite';
20
- import './chunk-utils-timers.8fca243e.js';
21
+ import './chunk-utils-timers.d1fcc6bb.js';
21
22
  import 'chai';
22
23
 
23
24
  let _viteNode;
package/globals.d.ts CHANGED
@@ -3,6 +3,8 @@ declare global {
3
3
  const test: typeof import('vitest')['test']
4
4
  const describe: typeof import('vitest')['describe']
5
5
  const it: typeof import('vitest')['it']
6
+ const expectTypeOf: typeof import('vitest')['expectTypeOf']
7
+ const assertType: typeof import('vitest')['assertType']
6
8
  const expect: typeof import('vitest')['expect']
7
9
  const assert: typeof import('vitest')['assert']
8
10
  const vitest: typeof import('vitest')['vitest']
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.24.5",
4
+ "version": "0.25.0",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -103,9 +103,12 @@
103
103
  "@types/chai": "^4.3.3",
104
104
  "@types/chai-subset": "^1.3.3",
105
105
  "@types/node": "*",
106
+ "acorn": "^8.8.0",
107
+ "acorn-walk": "^8.2.0",
106
108
  "chai": "^4.3.6",
107
109
  "debug": "^4.3.4",
108
110
  "local-pkg": "^0.4.2",
111
+ "source-map": "^0.6.1",
109
112
  "strip-literal": "^0.4.2",
110
113
  "tinybench": "^2.3.1",
111
114
  "tinypool": "^0.3.0",
@@ -114,7 +117,7 @@
114
117
  },
115
118
  "devDependencies": {
116
119
  "@antfu/install-pkg": "^0.1.1",
117
- "@edge-runtime/vm": "1.1.0",
120
+ "@edge-runtime/vm": "2.0.1",
118
121
  "@sinonjs/fake-timers": "^9.1.2",
119
122
  "@types/diff": "^5.0.2",
120
123
  "@types/jsdom": "^20.0.0",
@@ -122,7 +125,7 @@
122
125
  "@types/natural-compare": "^1.4.1",
123
126
  "@types/prompts": "^2.4.1",
124
127
  "@types/sinonjs__fake-timers": "^8.1.2",
125
- "@vitest/ui": "0.24.5",
128
+ "@vitest/ui": "0.25.0",
126
129
  "birpc": "^0.2.3",
127
130
  "cac": "^6.7.14",
128
131
  "chai-subset": "^1.6.0",
@@ -130,11 +133,13 @@
130
133
  "diff": "^5.1.0",
131
134
  "event-target-polyfill": "^0.0.3",
132
135
  "execa": "^6.1.0",
136
+ "expect-type": "^0.15.0",
133
137
  "fast-glob": "^3.2.12",
134
138
  "find-up": "^6.3.0",
135
139
  "flatted": "^3.2.7",
136
- "happy-dom": "^6.0.4",
137
- "jsdom": "^20.0.1",
140
+ "get-tsconfig": "^4.2.0",
141
+ "happy-dom": "^7.6.6",
142
+ "jsdom": "^20.0.2",
138
143
  "log-update": "^5.0.1",
139
144
  "magic-string": "^0.26.7",
140
145
  "micromatch": "^4.0.5",
@@ -143,15 +148,14 @@
143
148
  "p-limit": "^4.0.0",
144
149
  "pathe": "^0.2.0",
145
150
  "picocolors": "^1.0.0",
146
- "pkg-types": "^0.3.5",
151
+ "pkg-types": "^0.3.6",
147
152
  "pretty-format": "^27.5.1",
148
153
  "prompts": "^2.4.2",
149
154
  "rollup": "^2.79.1",
150
- "source-map-js": "^1.0.2",
151
155
  "strip-ansi": "^7.0.1",
152
156
  "typescript": "^4.8.4",
153
- "vite-node": "0.24.5",
154
- "ws": "^8.10.0"
157
+ "vite-node": "0.25.0",
158
+ "ws": "^8.11.0"
155
159
  },
156
160
  "scripts": {
157
161
  "build": "rimraf dist && rollup -c",
@@ -1,25 +0,0 @@
1
- import { m as globalApis } from './chunk-utils-env.b1281522.js';
2
- import { i as index } from './chunk-runtime-hooks.d748b085.js';
3
- import 'tty';
4
- import 'url';
5
- import 'path';
6
- import './chunk-runtime-chain.37ec5d73.js';
7
- import 'util';
8
- import './chunk-mock-date.030959d3.js';
9
- import 'local-pkg';
10
- import 'chai';
11
- import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.b418c0ab.js';
13
- import './chunk-utils-timers.8fca243e.js';
14
- import 'fs';
15
- import './chunk-utils-source-map.663e2952.js';
16
- import './spy.js';
17
- import 'tinyspy';
18
-
19
- function registerApiGlobally() {
20
- globalApis.forEach((api) => {
21
- globalThis[api] = index[api];
22
- });
23
- }
24
-
25
- export { registerApiGlobally };