vitest 0.0.88 → 0.0.92

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.
package/bin/vitest.mjs CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  import { fileURLToPath } from 'url'
4
4
  import { resolve } from 'path'
5
+ import { ensurePackageInstalled } from '../dist/utils.js'
5
6
 
6
7
  const argv = process.argv.slice(2)
7
8
 
8
9
  if (argv.includes('--coverage')) {
10
+ if (!await ensurePackageInstalled('c8'))
11
+ process.exit(1)
9
12
  const filename = fileURLToPath(import.meta.url)
10
13
  const entry = resolve(filename, '../../dist/cli.js')
11
14
  process.argv.splice(2, 0, process.argv[0], entry)
package/dist/cli.js CHANGED
@@ -1,22 +1,24 @@
1
+ import require$$0 from 'readline';
1
2
  import { EventEmitter } from 'events';
2
- import { c } from './error-c5d734a1.js';
3
- import { c as createVitest } from './index-af5d5277.js';
4
- import 'fs';
5
- import 'path';
3
+ import { c, e as ensurePackageInstalled } from './utils-860e5f7e.js';
4
+ import { c as createVitest } from './index-40ecbcb4.js';
6
5
  import 'tty';
7
- import 'source-map';
8
- import './utils-9dcc4050.js';
6
+ import 'local-pkg';
7
+ import 'path';
9
8
  import 'vite';
10
9
  import 'process';
11
- import './constants-adef7ffb.js';
10
+ import 'fs';
11
+ import 'fast-glob';
12
+ import 'util';
13
+ import './constants-9cfa4d7b.js';
12
14
  import 'url';
13
15
  import 'perf_hooks';
16
+ import './error-4b0c4b4b.js';
17
+ import 'source-map';
18
+ import './index-5cc247ff.js';
14
19
  import 'assert';
15
20
  import 'worker_threads';
16
21
  import 'piscina';
17
- import 'fast-glob';
18
- import 'micromatch';
19
- import 'readline';
20
22
 
21
23
  function toArr(any) {
22
24
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -631,7 +633,7 @@ class CAC extends EventEmitter {
631
633
 
632
634
  const cac = (name = "") => new CAC(name);
633
635
 
634
- var version = "0.0.88";
636
+ var version = "0.0.92";
635
637
 
636
638
  const cli = cac("vitest");
637
639
  cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
@@ -657,8 +659,13 @@ async function run(cliFilters, options) {
657
659
  const ctx = await createVitest(options);
658
660
  process.__vitest__ = ctx;
659
661
  process.chdir(ctx.config.root);
662
+ registerConsoleShortcuts(ctx);
663
+ if (ctx.config.environment && ctx.config.environment !== "node") {
664
+ if (!await ensurePackageInstalled(ctx.config.environment))
665
+ process.exit(1);
666
+ }
660
667
  try {
661
- await ctx.run(cliFilters);
668
+ await ctx.start(cliFilters);
662
669
  } catch (e) {
663
670
  process.exitCode = 1;
664
671
  throw e;
@@ -667,3 +674,17 @@ async function run(cliFilters, options) {
667
674
  await ctx.close();
668
675
  }
669
676
  }
677
+ function registerConsoleShortcuts(ctx) {
678
+ if (process.stdin.isTTY) {
679
+ require$$0.emitKeypressEvents(process.stdin);
680
+ process.stdin.setRawMode(true);
681
+ process.stdin.on("keypress", (str) => {
682
+ if (str === "" || str === "")
683
+ process.exit();
684
+ if (ctx.runningPromise)
685
+ return;
686
+ if (ctx.isFirstRun)
687
+ process.exit();
688
+ });
689
+ }
690
+ }
@@ -22,9 +22,8 @@ const globalApis = [
22
22
  "chai",
23
23
  "expect",
24
24
  "assert",
25
- "spy",
26
- "spyOn",
27
25
  "vitest",
26
+ "vi",
28
27
  "beforeAll",
29
28
  "afterAll",
30
29
  "beforeEach",