vitest 0.18.1 → 0.20.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 (38) hide show
  1. package/LICENSE.md +5 -5
  2. package/dist/browser.d.ts +1890 -0
  3. package/dist/browser.mjs +22 -0
  4. package/dist/{chunk-api-setup.9d3f7670.mjs → chunk-api-setup.7c4c8879.mjs} +24 -6
  5. package/dist/{chunk-constants.d4406290.mjs → chunk-constants.16825f0c.mjs} +5 -4
  6. package/dist/{chunk-env-node.bbba78e5.mjs → chunk-defaults.1c51d585.mjs} +461 -457
  7. package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
  8. package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
  9. package/dist/{chunk-utils-global.0a7416cf.mjs → chunk-mock-date.9160e13b.mjs} +16 -41
  10. package/dist/chunk-node-git.43dbdd42.mjs +1139 -0
  11. package/dist/chunk-runtime-chain.b6c2cdbc.mjs +2041 -0
  12. package/dist/chunk-runtime-error.0aa0dc06.mjs +648 -0
  13. package/dist/{chunk-runtime-chain.b60d57da.mjs → chunk-runtime-hooks.3ee34848.mjs} +14 -2014
  14. package/dist/{chunk-runtime-mocker.1d853e3a.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
  15. package/dist/{chunk-runtime-rpc.9d1f4c48.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
  16. package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
  17. package/dist/{chunk-utils-source-map.c03f8bc4.mjs → chunk-utils-source-map.8198ebd9.mjs} +2 -2
  18. package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
  19. package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
  20. package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
  21. package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.2e90dadf.mjs} +165 -1182
  22. package/dist/{chunk-vite-node-utils.8077cd3c.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -312
  23. package/dist/cli.mjs +10 -10
  24. package/dist/config.cjs +6 -3
  25. package/dist/config.d.ts +2 -0
  26. package/dist/config.mjs +6 -3
  27. package/dist/entry.mjs +17 -598
  28. package/dist/index.d.ts +81 -6
  29. package/dist/index.mjs +10 -5
  30. package/dist/loader.mjs +35 -0
  31. package/dist/node.d.ts +71 -4
  32. package/dist/node.mjs +13 -12
  33. package/dist/suite.mjs +15 -0
  34. package/dist/vendor-index.61438b77.mjs +335 -0
  35. package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
  36. package/dist/worker.mjs +9 -6
  37. package/package.json +12 -4
  38. package/dist/chunk-integrations-globals.00b6e1ad.mjs +0 -23
@@ -2,11 +2,9 @@ import childProcess from 'child_process';
2
2
  import path$3 from 'path';
3
3
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
4
4
  import fs$1 from 'fs';
5
- import assert$1 from 'assert';
6
- import require$$2 from 'events';
7
- import require$$0$2 from 'buffer';
5
+ import require$$0$1 from 'buffer';
8
6
  import require$$0 from 'stream';
9
- import require$$0$1 from 'util';
7
+ import util from 'util';
10
8
 
11
9
  var crossSpawn = {exports: {}};
12
10
 
@@ -456,7 +454,7 @@ const resolveCommand = resolveCommand_1;
456
454
  const escape = _escape;
457
455
  const readShebang = readShebang_1;
458
456
 
459
- const isWin$2 = process.platform === 'win32';
457
+ const isWin$1 = process.platform === 'win32';
460
458
  const isExecutableRegExp = /\.(?:com|exe)$/i;
461
459
  const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
462
460
 
@@ -476,7 +474,7 @@ function detectShebang(parsed) {
476
474
  }
477
475
 
478
476
  function parseNonShell(parsed) {
479
- if (!isWin$2) {
477
+ if (!isWin$1) {
480
478
  return parsed;
481
479
  }
482
480
 
@@ -541,7 +539,7 @@ function parse$1(command, args, options) {
541
539
 
542
540
  var parse_1 = parse$1;
543
541
 
544
- const isWin$1 = process.platform === 'win32';
542
+ const isWin = process.platform === 'win32';
545
543
 
546
544
  function notFoundError(original, syscall) {
547
545
  return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
@@ -554,7 +552,7 @@ function notFoundError(original, syscall) {
554
552
  }
555
553
 
556
554
  function hookChildProcess(cp, parsed) {
557
- if (!isWin$1) {
555
+ if (!isWin) {
558
556
  return;
559
557
  }
560
558
 
@@ -577,7 +575,7 @@ function hookChildProcess(cp, parsed) {
577
575
  }
578
576
 
579
577
  function verifyENOENT(status, parsed) {
580
- if (isWin$1 && status === 1 && !parsed.file) {
578
+ if (isWin && status === 1 && !parsed.file) {
581
579
  return notFoundError(parsed.original, 'spawn');
582
580
  }
583
581
 
@@ -585,7 +583,7 @@ function verifyENOENT(status, parsed) {
585
583
  }
586
584
 
587
585
  function verifyENOENTSync(status, parsed) {
588
- if (isWin$1 && status === 1 && !parsed.file) {
586
+ if (isWin && status === 1 && !parsed.file) {
589
587
  return notFoundError(parsed.original, 'spawnSync');
590
588
  }
591
589
 
@@ -637,276 +635,6 @@ crossSpawn.exports.sync = spawnSync;
637
635
  crossSpawn.exports._parse = parse;
638
636
  crossSpawn.exports._enoent = enoent;
639
637
 
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
-
910
638
  var getStream$1 = {exports: {}};
911
639
 
912
640
  const {PassThrough: PassThroughStream} = require$$0;
@@ -961,9 +689,9 @@ var bufferStream$1 = options => {
961
689
  return stream;
962
690
  };
963
691
 
964
- const {constants: BufferConstants} = require$$0$2;
692
+ const {constants: BufferConstants} = require$$0$1;
965
693
  const stream = require$$0;
966
- const {promisify} = require$$0$1;
694
+ const {promisify} = util;
967
695
  const bufferStream = bufferStream$1;
968
696
 
969
697
  const streamPipelinePromisified = promisify(stream.pipeline);
@@ -1062,64 +790,4 @@ var mergeStream = function (/*streams...*/) {
1062
790
  }
1063
791
  };
1064
792
 
1065
- var onetime$1 = {exports: {}};
1066
-
1067
- var mimicFn$2 = {exports: {}};
1068
-
1069
- const mimicFn$1 = (to, from) => {
1070
- for (const prop of Reflect.ownKeys(from)) {
1071
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
1072
- }
1073
-
1074
- return to;
1075
- };
1076
-
1077
- mimicFn$2.exports = mimicFn$1;
1078
- // TODO: Remove this for the next major release
1079
- mimicFn$2.exports.default = mimicFn$1;
1080
-
1081
- const mimicFn = mimicFn$2.exports;
1082
-
1083
- const calledFunctions = new WeakMap();
1084
-
1085
- const onetime = (function_, options = {}) => {
1086
- if (typeof function_ !== 'function') {
1087
- throw new TypeError('Expected a function');
1088
- }
1089
-
1090
- let returnValue;
1091
- let callCount = 0;
1092
- const functionName = function_.displayName || function_.name || '<anonymous>';
1093
-
1094
- const onetime = function (...arguments_) {
1095
- calledFunctions.set(onetime, ++callCount);
1096
-
1097
- if (callCount === 1) {
1098
- returnValue = function_.apply(this, arguments_);
1099
- function_ = null;
1100
- } else if (options.throw === true) {
1101
- throw new Error(`Function \`${functionName}\` can only be called once`);
1102
- }
1103
-
1104
- return returnValue;
1105
- };
1106
-
1107
- mimicFn(onetime, function_);
1108
- calledFunctions.set(onetime, callCount);
1109
-
1110
- return onetime;
1111
- };
1112
-
1113
- onetime$1.exports = onetime;
1114
- // TODO: Remove this for the next major release
1115
- onetime$1.exports.default = onetime;
1116
-
1117
- onetime$1.exports.callCount = function_ => {
1118
- if (!calledFunctions.has(function_)) {
1119
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
1120
- }
1121
-
1122
- return calledFunctions.get(function_);
1123
- };
1124
-
1125
- export { crossSpawn as c, getStream$1 as g, mergeStream as m, onetime$1 as o, pathKey$1 as p, signalExit as s };
793
+ export { crossSpawn as c, getStream$1 as g, mergeStream as m, pathKey$1 as p };
package/dist/worker.mjs CHANGED
@@ -1,20 +1,23 @@
1
- import { q as resolve, a as getWorkerState } from './chunk-utils-global.0a7416cf.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.8077cd3c.mjs';
1
+ import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.a247c2c2.mjs';
3
3
  import { workerId } from 'tinypool';
4
- import { d as distDir } from './chunk-constants.d4406290.mjs';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.1d853e3a.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.9d1f4c48.mjs';
4
+ import { d as distDir } from './chunk-constants.16825f0c.mjs';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.0a8f7c5e.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
7
+ import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
7
8
  import 'path';
8
9
  import 'tty';
9
10
  import 'local-pkg';
10
11
  import 'module';
11
12
  import 'url';
12
13
  import 'vm';
14
+ import './chunk-vite-node-utils.9dfd1e3f.mjs';
13
15
  import 'fs';
14
16
  import 'assert';
15
17
  import 'util';
16
18
  import 'debug';
17
19
  import 'vite';
20
+ import './chunk-utils-timers.b48455ed.mjs';
18
21
 
19
22
  let _viteNode;
20
23
  const moduleCache = new ModuleCacheMap();
@@ -77,7 +80,7 @@ function init(ctx) {
77
80
  if (ctx.invalidates) {
78
81
  ctx.invalidates.forEach((fsPath) => {
79
82
  moduleCache.delete(fsPath);
80
- moduleCache.delete(`${fsPath}__mock`);
83
+ moduleCache.delete(`mock:${fsPath}`);
81
84
  });
82
85
  }
83
86
  ctx.files.forEach((i) => moduleCache.delete(i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.18.1",
3
+ "version": "0.20.0",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -35,6 +35,10 @@
35
35
  "types": "./dist/node.d.ts",
36
36
  "import": "./dist/node.mjs"
37
37
  },
38
+ "./browser": {
39
+ "types": "./dist/browser.d.ts",
40
+ "import": "./dist/browser.mjs"
41
+ },
38
42
  "./config": {
39
43
  "types": "./config.d.ts",
40
44
  "require": "./dist/config.cjs",
@@ -58,6 +62,7 @@
58
62
  },
59
63
  "peerDependencies": {
60
64
  "@edge-runtime/vm": "*",
65
+ "@vitest/browser": "*",
61
66
  "@vitest/ui": "*",
62
67
  "c8": "*",
63
68
  "happy-dom": "*",
@@ -67,6 +72,9 @@
67
72
  "@vitest/ui": {
68
73
  "optional": true
69
74
  },
75
+ "@vitest/browser": {
76
+ "optional": true
77
+ },
70
78
  "c8": {
71
79
  "optional": true
72
80
  },
@@ -101,7 +109,7 @@
101
109
  "@types/natural-compare": "^1.4.1",
102
110
  "@types/prompts": "^2.4.0",
103
111
  "@types/sinonjs__fake-timers": "^8.1.2",
104
- "@vitest/ui": "0.18.1",
112
+ "@vitest/ui": "0.20.0",
105
113
  "birpc": "^0.2.3",
106
114
  "c8": "^7.11.3",
107
115
  "cac": "^6.7.12",
@@ -129,11 +137,11 @@
129
137
  "source-map-js": "^1.0.2",
130
138
  "strip-ansi": "^7.0.1",
131
139
  "typescript": "^4.7.4",
132
- "vite-node": "0.18.1",
140
+ "vite-node": "0.20.0",
133
141
  "ws": "^8.8.1"
134
142
  },
135
143
  "scripts": {
136
144
  "build": "rimraf dist && rollup -c",
137
- "dev": "rollup -c --watch -m inline"
145
+ "dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline"
138
146
  }
139
147
  }
@@ -1,23 +0,0 @@
1
- import { g as globalApis } from './chunk-constants.d4406290.mjs';
2
- import { i as index } from './chunk-runtime-chain.b60d57da.mjs';
3
- import 'url';
4
- import './chunk-utils-global.0a7416cf.mjs';
5
- import 'path';
6
- import 'tty';
7
- import 'local-pkg';
8
- import 'util';
9
- import 'chai';
10
- import './vendor-_commonjsHelpers.4da45ef5.mjs';
11
- import './chunk-runtime-rpc.9d1f4c48.mjs';
12
- import 'fs';
13
- import './chunk-utils-source-map.c03f8bc4.mjs';
14
- import './spy.mjs';
15
- import 'tinyspy';
16
-
17
- function registerApiGlobally() {
18
- globalApis.forEach((api) => {
19
- globalThis[api] = index[api];
20
- });
21
- }
22
-
23
- export { registerApiGlobally };