vitest 0.0.91 → 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,12 +2,13 @@
2
2
 
3
3
  import { fileURLToPath } from 'url'
4
4
  import { resolve } from 'path'
5
- import { checkPeerDependency } from '../dist/utils.js'
5
+ import { ensurePackageInstalled } from '../dist/utils.js'
6
6
 
7
7
  const argv = process.argv.slice(2)
8
8
 
9
9
  if (argv.includes('--coverage')) {
10
- checkPeerDependency('c8/bin/c8.js')
10
+ if (!await ensurePackageInstalled('c8'))
11
+ process.exit(1)
11
12
  const filename = fileURLToPath(import.meta.url)
12
13
  const entry = resolve(filename, '../../dist/cli.js')
13
14
  process.argv.splice(2, 0, process.argv[0], entry)
package/dist/cli.js CHANGED
@@ -1,23 +1,24 @@
1
- import readline from 'readline';
1
+ import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { c } from './utils-5d0cec8a.js';
4
- import { c as createVitest } from './index-25bef3dd.js';
5
- import 'module';
3
+ import { c, e as ensurePackageInstalled } from './utils-860e5f7e.js';
4
+ import { c as createVitest } from './index-40ecbcb4.js';
6
5
  import 'tty';
6
+ import 'local-pkg';
7
7
  import 'path';
8
8
  import 'vite';
9
9
  import 'process';
10
10
  import 'fs';
11
+ import 'fast-glob';
12
+ import 'util';
11
13
  import './constants-9cfa4d7b.js';
12
14
  import 'url';
13
15
  import 'perf_hooks';
14
- import './error-abd1f726.js';
16
+ import './error-4b0c4b4b.js';
15
17
  import 'source-map';
18
+ import './index-5cc247ff.js';
16
19
  import 'assert';
17
20
  import 'worker_threads';
18
21
  import 'piscina';
19
- import 'fast-glob';
20
- import 'micromatch';
21
22
 
22
23
  function toArr(any) {
23
24
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -632,7 +633,7 @@ class CAC extends EventEmitter {
632
633
 
633
634
  const cac = (name = "") => new CAC(name);
634
635
 
635
- var version = "0.0.91";
636
+ var version = "0.0.92";
636
637
 
637
638
  const cli = cac("vitest");
638
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", {
@@ -659,6 +660,10 @@ async function run(cliFilters, options) {
659
660
  process.__vitest__ = ctx;
660
661
  process.chdir(ctx.config.root);
661
662
  registerConsoleShortcuts(ctx);
663
+ if (ctx.config.environment && ctx.config.environment !== "node") {
664
+ if (!await ensurePackageInstalled(ctx.config.environment))
665
+ process.exit(1);
666
+ }
662
667
  try {
663
668
  await ctx.start(cliFilters);
664
669
  } catch (e) {
@@ -671,7 +676,7 @@ async function run(cliFilters, options) {
671
676
  }
672
677
  function registerConsoleShortcuts(ctx) {
673
678
  if (process.stdin.isTTY) {
674
- readline.emitKeypressEvents(process.stdin);
679
+ require$$0.emitKeypressEvents(process.stdin);
675
680
  process.stdin.setRawMode(true);
676
681
  process.stdin.on("keypress", (str) => {
677
682
  if (str === "" || str === "")
package/dist/entry.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs, { promises } from 'fs';
1
2
  import { Console } from 'console';
2
3
  import { Writable } from 'stream';
3
4
  import { importModule } from 'local-pkg';
@@ -5,13 +6,11 @@ import chai, { expect, util } from 'chai';
5
6
  import Subset from 'chai-subset';
6
7
  import path, { basename } from 'path';
7
8
  import { r as rpc, s as send } from './rpc-7de86f29.js';
8
- import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, d as hasTests, h as hasFailed } from './utils-5d0cec8a.js';
9
- import fs from 'fs';
10
- import { u as unifiedDiff } from './error-abd1f726.js';
9
+ import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, d as hasTests, h as hasFailed } from './utils-860e5f7e.js';
10
+ import { u as unifiedDiff } from './error-4b0c4b4b.js';
11
11
  import { performance } from 'perf_hooks';
12
12
  import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-b8c6cb53.js';
13
13
  import { n as nanoid } from './index-9e71c815.js';
14
- import 'module';
15
14
  import 'tty';
16
15
  import 'source-map';
17
16
 
@@ -3884,10 +3883,17 @@ async function startTests(paths, config) {
3884
3883
  }
3885
3884
 
3886
3885
  async function run(files, config) {
3886
+ var _a;
3887
3887
  await setupGlobalEnv(config);
3888
- await withEnv(config.environment, async () => {
3889
- await startTests(files, config);
3890
- });
3888
+ for (const file of files) {
3889
+ const code = await promises.readFile(file, "utf-8");
3890
+ const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
3891
+ if (!["node", "jsdom", "happy-dom"].includes(env))
3892
+ throw new Error(`Unsupported environment: ${env}`);
3893
+ await withEnv(env, async () => {
3894
+ await startTests([file], config);
3895
+ });
3896
+ }
3891
3897
  }
3892
3898
 
3893
3899
  export { run };
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { relative } from 'path';
3
- import { n as notNullish, c } from './utils-5d0cec8a.js';
3
+ import { n as notNullish, c } from './utils-860e5f7e.js';
4
4
  import { SourceMapConsumer } from 'source-map';
5
5
 
6
6
  function Diff() {}