vitest 0.0.98 → 0.0.99

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.
@@ -0,0 +1,7 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ function commonjsRequire (path) {
4
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
5
+ }
6
+
7
+ export { commonjsRequire as a, commonjsGlobal as c };
package/dist/cli.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { e as ensurePackageInstalled, c } from './utils-70b78878.js';
4
- import { c as createVitest } from './index-0697046c.js';
3
+ import { e as ensurePackageInstalled } from './utils-b780070b.js';
4
+ import { c as createVitest } from './index-d5bb350e.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
- import './index-1488b423.js';
8
7
  import 'path';
9
8
  import 'vite';
10
9
  import 'process';
11
10
  import 'fs';
12
- import 'fast-glob';
11
+ import 'os';
13
12
  import 'util';
14
- import './constants-e78c749a.js';
13
+ import 'stream';
14
+ import './constants-3cbd9066.js';
15
15
  import 'url';
16
16
  import 'perf_hooks';
17
- import './error-2437ee7f.js';
18
- import 'source-map';
19
- import './index-5cc247ff.js';
17
+ import './error-34c1d9e5.js';
18
+ import './index-825cb54c.js';
19
+ import './_commonjsHelpers-bdec4bbd.js';
20
20
  import 'assert';
21
21
  import 'worker_threads';
22
22
  import 'tinypool';
@@ -634,10 +634,10 @@ class CAC extends EventEmitter {
634
634
 
635
635
  const cac = (name = "") => new CAC(name);
636
636
 
637
- var version = "0.0.98";
637
+ var version = "0.0.99";
638
638
 
639
639
  const cli = cac("vitest");
640
- 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", {
640
+ 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("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
641
641
  default: "node"
642
642
  }).help();
643
643
  cli.command("run [...filters]").action(run);
@@ -645,10 +645,9 @@ cli.command("watch [...filters]").action(dev);
645
645
  cli.command("dev [...filters]").action(dev);
646
646
  cli.command("[...filters]").action(dev);
647
647
  cli.parse();
648
- const PROCESS_EXIT_TIMEOUT = 5e3;
649
648
  async function dev(cliFilters, argv) {
650
649
  if (argv.watch == null)
651
- argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE;
650
+ argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE && !argv.silent && !argv.run;
652
651
  await run(cliFilters, argv);
653
652
  }
654
653
  async function run(cliFilters, options) {
@@ -673,13 +672,8 @@ async function run(cliFilters, options) {
673
672
  if (!ctx.config.watch)
674
673
  await ctx.close();
675
674
  }
676
- if (!ctx.config.watch) {
677
- const timer = setTimeout(() => {
678
- console.error(c.red("Process hanging for 5 seconds after all tests are done. Exiting..."));
679
- process.exit(1);
680
- }, PROCESS_EXIT_TIMEOUT);
681
- timer.unref();
682
- }
675
+ if (!ctx.config.watch)
676
+ process.exit();
683
677
  }
684
678
  function registerConsoleShortcuts(ctx) {
685
679
  if (process.stdin.isTTY) {
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { a as resolve } from './index-1488b423.js';
2
+ import { h as resolve } from './utils-b780070b.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
package/dist/entry.js CHANGED
@@ -2,19 +2,16 @@ import fs, { promises } from 'fs';
2
2
  import { Console } from 'console';
3
3
  import { Writable } from 'stream';
4
4
  import { importModule } from 'local-pkg';
5
- import chai, { expect, util } from 'chai';
6
- import Subset from 'chai-subset';
7
- import { c as index, b as basename } from './index-1488b423.js';
5
+ import { e as expect, f as chai$1, u as util, h as setHooks, j as createSuiteHooks, k as clearContext, l as defaultSuite, m as context, n as getHooks, o as getFn } from './index-aa25bceb.js';
6
+ import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
7
+ import { l as index, g as getNames, c as c$1, t as toArray, b as basename, m as interpretOnlyMode, p as partitionSuiteChildren, o as hasTests, j as hasFailed } from './utils-b780070b.js';
8
8
  import { r as rpc, s as send } from './rpc-7de86f29.js';
9
- import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, f as hasTests, h as hasFailed } from './utils-70b78878.js';
10
- import { u as unifiedDiff } from './error-2437ee7f.js';
9
+ import { u as unifiedDiff } from './error-34c1d9e5.js';
11
10
  import { performance } from 'perf_hooks';
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
11
  import { n as nanoid } from './index-9e71c815.js';
14
12
  import { format as format$1 } from 'util';
15
- import 'path';
16
13
  import 'tty';
17
- import 'source-map';
14
+ import 'path';
18
15
 
19
16
  var node = {
20
17
  name: "node",
@@ -298,6 +295,91 @@ const environments = {
298
295
  "happy-dom": happy
299
296
  };
300
297
 
298
+ var chaiSubset = {exports: {}};
299
+
300
+ (function (module, exports) {
301
+ (function() {
302
+ (function(chaiSubset) {
303
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
304
+ return module.exports = chaiSubset;
305
+ } else {
306
+ return chai.use(chaiSubset);
307
+ }
308
+ })(function(chai, utils) {
309
+ var Assertion = chai.Assertion;
310
+ var assertionPrototype = Assertion.prototype;
311
+
312
+ Assertion.addMethod('containSubset', function (expected) {
313
+ var actual = utils.flag(this, 'object');
314
+ var showDiff = chai.config.showDiff;
315
+
316
+ assertionPrototype.assert.call(this,
317
+ compare(expected, actual),
318
+ 'expected #{act} to contain subset #{exp}',
319
+ 'expected #{act} to not contain subset #{exp}',
320
+ expected,
321
+ actual,
322
+ showDiff
323
+ );
324
+ });
325
+
326
+ chai.assert.containSubset = function(val, exp, msg) {
327
+ new chai.Assertion(val, msg).to.be.containSubset(exp);
328
+ };
329
+
330
+ function compare(expected, actual) {
331
+ if (expected === actual) {
332
+ return true;
333
+ }
334
+ if (typeof(actual) !== typeof(expected)) {
335
+ return false;
336
+ }
337
+ if (typeof(expected) !== 'object' || expected === null) {
338
+ return expected === actual;
339
+ }
340
+ if (!!expected && !actual) {
341
+ return false;
342
+ }
343
+
344
+ if (Array.isArray(expected)) {
345
+ if (typeof(actual.length) !== 'number') {
346
+ return false;
347
+ }
348
+ var aa = Array.prototype.slice.call(actual);
349
+ return expected.every(function (exp) {
350
+ return aa.some(function (act) {
351
+ return compare(exp, act);
352
+ });
353
+ });
354
+ }
355
+
356
+ if (expected instanceof Date) {
357
+ if (actual instanceof Date) {
358
+ return expected.getTime() === actual.getTime();
359
+ } else {
360
+ return false;
361
+ }
362
+ }
363
+
364
+ return Object.keys(expected).every(function (key) {
365
+ var eo = expected[key];
366
+ var ao = actual[key];
367
+ if (typeof(eo) === 'object' && eo !== null && ao !== null) {
368
+ return compare(eo, ao);
369
+ }
370
+ if (typeof(eo) === 'function') {
371
+ return eo(ao);
372
+ }
373
+ return ao === eo;
374
+ });
375
+ }
376
+ });
377
+
378
+ }).call(commonjsGlobal);
379
+ }(chaiSubset));
380
+
381
+ var Subset = chaiSubset.exports;
382
+
301
383
  var naturalCompare$2 = {exports: {}};
302
384
 
303
385
  /*
@@ -3407,7 +3489,7 @@ function JestExtendPlugin(expects) {
3407
3489
  c.expect.fail(message());
3408
3490
  }
3409
3491
  const expectAssertionWrapper = isAsyncFunction(expectAssertion) ? expectAsyncWrapper : expectSyncWrapper;
3410
- utils.addMethod(chai.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
3492
+ utils.addMethod(chai$1.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
3411
3493
  });
3412
3494
  };
3413
3495
  }
@@ -3788,11 +3870,11 @@ let installed = false;
3788
3870
  async function setupChai() {
3789
3871
  if (installed)
3790
3872
  return;
3791
- chai.use(JestExtend);
3792
- chai.use(JestChaiExpect);
3793
- chai.use(Subset);
3794
- chai.use(SnapshotPlugin);
3795
- chai.use(JestAsymmetricMatchers);
3873
+ chai$1.use(JestExtend);
3874
+ chai$1.use(JestChaiExpect);
3875
+ chai$1.use(Subset);
3876
+ chai$1.use(SnapshotPlugin);
3877
+ chai$1.use(JestAsymmetricMatchers);
3796
3878
  installed = true;
3797
3879
  }
3798
3880
 
@@ -3804,7 +3886,7 @@ async function setupGlobalEnv(config) {
3804
3886
  setupConsoleLogSpy();
3805
3887
  await setupChai();
3806
3888
  if (config.global)
3807
- (await import('./global-97ee5fb8.js')).registerApiGlobally();
3889
+ (await import('./global-0be1f687.js')).registerApiGlobally();
3808
3890
  }
3809
3891
  function setupConsoleLogSpy() {
3810
3892
  const stdout = new Writable({
@@ -3959,6 +4041,15 @@ async function runTest(test) {
3959
4041
  test.result.state = "fail";
3960
4042
  test.result.error = processError(e);
3961
4043
  }
4044
+ if (test.fails) {
4045
+ if (test.result.state === "pass") {
4046
+ test.result.state = "fail";
4047
+ test.result.error = processError(new Error("Expect test to fail"));
4048
+ } else {
4049
+ test.result.state = "pass";
4050
+ test.result.error = void 0;
4051
+ }
4052
+ }
3962
4053
  getSnapshotClient().clearTest();
3963
4054
  test.result.end = performance.now();
3964
4055
  process.__vitest_worker__.current = void 0;