@vitest/runner 1.0.0-beta.4 → 1.0.0-beta.6

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/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { VitestRunner } from './types.js';
2
2
  export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
3
- import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, a as Test, C as Custom } from './tasks-0309a91e.js';
4
- export { D as DoneCallback, E as ExtendedContext, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, w as RuntimeContext, z as SequenceHooks, A as SequenceSetupFiles, S as Suite, v as SuiteFactory, j as TaskBase, y as TaskContext, u as TaskCustomOptions, l as TaskMeta, k as TaskPopulated, m as TaskResult, n as TaskResultPack, i as TaskState, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-0309a91e.js';
3
+ import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, a as Test, C as Custom } from './tasks-rsXe_qLO.js';
4
+ export { D as DoneCallback, E as ExtendedContext, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, w as RuntimeContext, z as SequenceHooks, A as SequenceSetupFiles, S as Suite, v as SuiteFactory, j as TaskBase, y as TaskContext, u as TaskCustomOptions, l as TaskMeta, k as TaskPopulated, m as TaskResult, n as TaskResultPack, i as TaskState, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-rsXe_qLO.js';
5
5
  import { Awaitable } from '@vitest/utils';
6
6
  export { processError } from '@vitest/utils/error';
7
+ import '@vitest/utils/diff';
7
8
 
8
9
  declare function updateTask(task: Task, runner: VitestRunner): void;
9
10
  declare function startTests(paths: string[], runner: VitestRunner): Promise<File[]>;
package/dist/index.js CHANGED
@@ -167,7 +167,7 @@ function withFixtures(fn, testContext) {
167
167
  else
168
168
  return isFn ? value(context, use) : use(value);
169
169
  }
170
- const setupFixturePromise = next();
170
+ const setupFixturePromise = next().catch(reject);
171
171
  cleanupFnArray.unshift(() => setupFixturePromise);
172
172
  });
173
173
  };
@@ -296,7 +296,7 @@ function createSuiteCollector(name, factory = () => {
296
296
  meta: options.meta ?? /* @__PURE__ */ Object.create(null)
297
297
  };
298
298
  const handler = options.handler;
299
- if (options.concurrent || !sequential && (concurrent || runner.config.sequence.concurrent))
299
+ if (options.concurrent || !options.sequential && runner.config.sequence.concurrent)
300
300
  task2.concurrent = true;
301
301
  if (shuffle)
302
302
  task2.shuffle = true;
@@ -315,11 +315,13 @@ function createSuiteCollector(name, factory = () => {
315
315
  tasks.push(task2);
316
316
  return task2;
317
317
  };
318
- const test2 = createTest(function(name2, fn = noop, options) {
318
+ const test2 = createTest(function(name2, fn = noop, options = {}) {
319
319
  if (typeof options === "number")
320
320
  options = { timeout: options };
321
321
  if (typeof suiteOptions === "object")
322
322
  options = Object.assign({}, suiteOptions, options);
323
+ options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
324
+ options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
323
325
  const test3 = task(
324
326
  formatName(name2),
325
327
  { ...this, ...options, handler: fn }
@@ -352,7 +354,8 @@ function createSuiteCollector(name, factory = () => {
352
354
  each,
353
355
  shuffle,
354
356
  tasks: [],
355
- meta: /* @__PURE__ */ Object.create(null)
357
+ meta: /* @__PURE__ */ Object.create(null),
358
+ projectName: ""
356
359
  };
357
360
  setHooks(suite2, createSuiteHooks());
358
361
  }
@@ -381,14 +384,16 @@ function createSuiteCollector(name, factory = () => {
381
384
  return collector;
382
385
  }
383
386
  function createSuite() {
384
- function suiteFn(name, factory, options) {
387
+ function suiteFn(name, factory, options = {}) {
385
388
  const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
386
389
  const currentSuite = getCurrentSuite();
387
390
  if (typeof options === "number")
388
391
  options = { timeout: options };
389
392
  if (currentSuite == null ? void 0 : currentSuite.options)
390
393
  options = { ...currentSuite.options, ...options };
391
- return createSuiteCollector(formatName(name), factory, mode, this.concurrent, this.sequence, this.shuffle, this.each, options);
394
+ options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
395
+ options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
396
+ return createSuiteCollector(formatName(name), factory, mode, this.concurrent, this.sequential, this.shuffle, this.each, options);
392
397
  }
393
398
  suiteFn.each = function(cases, ...args) {
394
399
  const suite2 = this.withContext();
@@ -429,8 +434,12 @@ function createTaskCollector(fn, context) {
429
434
  this.setContext("each", void 0);
430
435
  };
431
436
  };
432
- taskFn.skipIf = (condition) => condition ? test.skip : test;
433
- taskFn.runIf = (condition) => condition ? test : test.skip;
437
+ taskFn.skipIf = function(condition) {
438
+ return condition ? this.skip : this;
439
+ };
440
+ taskFn.runIf = function(condition) {
441
+ return condition ? this : this.skip;
442
+ };
434
443
  taskFn.extend = function(fixtures) {
435
444
  const _context = mergeContextFixtures(fixtures, context);
436
445
  return createTest(function fn2(name, fn2, options) {
@@ -438,7 +447,7 @@ function createTaskCollector(fn, context) {
438
447
  }, _context);
439
448
  };
440
449
  const _test = createChainable(
441
- ["concurrent", "skip", "only", "todo", "fails"],
450
+ ["concurrent", "sequential", "skip", "only", "todo", "fails"],
442
451
  taskFn
443
452
  );
444
453
  if (context)
@@ -460,11 +469,11 @@ function formatTitle(template, items, idx) {
460
469
  if (isObject(items[0])) {
461
470
  formatted = formatted.replace(
462
471
  /\$([$\w_.]+)/g,
472
+ // https://github.com/chaijs/chai/pull/1490
463
473
  (_, key) => {
464
474
  var _a, _b;
465
475
  return objDisplay(objectAttr(items[0], key), { truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold });
466
476
  }
467
- // https://github.com/chaijs/chai/pull/1490
468
477
  );
469
478
  }
470
479
  return formatted;
@@ -791,7 +800,7 @@ async function runSuite(suite, runner) {
791
800
  failTask(suite.result, e, runner.config.diffOptions);
792
801
  }
793
802
  if (suite.mode === "run") {
794
- if (!hasTests(suite)) {
803
+ if (!runner.config.passWithNoTests && !hasTests(suite)) {
795
804
  suite.result.state = "fail";
796
805
  if (!((_c = suite.result.errors) == null ? void 0 : _c.length)) {
797
806
  const error = processError(new Error(`No test found in suite ${suite.name}`));
@@ -68,7 +68,7 @@ interface Suite extends TaskBase {
68
68
  type: 'suite';
69
69
  tasks: Task[];
70
70
  filepath?: string;
71
- projectName?: string;
71
+ projectName: string;
72
72
  }
73
73
  interface File extends Suite {
74
74
  filepath: string;
@@ -110,7 +110,7 @@ interface TestEachFunction {
110
110
  <T>(cases: ReadonlyArray<T>): (name: string | Function, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
111
111
  (...args: [TemplateStringsArray, ...any]): (name: string | Function, fn: (...args: any[]) => Awaitable<void>, options?: number | TestOptions) => void;
112
112
  }
113
- type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
113
+ type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'sequential' | 'only' | 'skip' | 'todo' | 'fails', [
114
114
  name: string | Function,
115
115
  fn?: TestFunction<ExtraContext>,
116
116
  options?: number | TestOptions
@@ -137,6 +137,16 @@ interface TestOptions {
137
137
  * @default 0
138
138
  */
139
139
  repeats?: number;
140
+ /**
141
+ * Whether tests run concurrently.
142
+ * Tests inherit `concurrent` from `describe()` and nested `describe()` will inherit from parent's `concurrent`.
143
+ */
144
+ concurrent?: boolean;
145
+ /**
146
+ * Whether tests run sequentially.
147
+ * Tests inherit `sequential` from `describe()` and nested `describe()` will inherit from parent's `sequential`.
148
+ */
149
+ sequential?: boolean;
140
150
  }
141
151
  interface ExtendedAPI<ExtraContext> {
142
152
  each: TestEachFunction;
package/dist/types.d.ts CHANGED
@@ -1,49 +1,8 @@
1
- import { z as SequenceHooks, A as SequenceSetupFiles, F as File, k as TaskPopulated, S as Suite, n as TaskResultPack, a as Test, C as Custom, y as TaskContext, E as ExtendedContext } from './tasks-0309a91e.js';
2
- export { g as CustomAPI, D as DoneCallback, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, R as RunMode, w as RuntimeContext, d as SuiteAPI, f as SuiteCollector, v as SuiteFactory, h as SuiteHooks, T as Task, j as TaskBase, u as TaskCustomOptions, l as TaskMeta, m as TaskResult, i as TaskState, e as TestAPI, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-0309a91e.js';
1
+ import { z as SequenceHooks, A as SequenceSetupFiles, F as File, k as TaskPopulated, S as Suite, n as TaskResultPack, a as Test, C as Custom, y as TaskContext, E as ExtendedContext } from './tasks-rsXe_qLO.js';
2
+ export { g as CustomAPI, D as DoneCallback, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, R as RunMode, w as RuntimeContext, d as SuiteAPI, f as SuiteCollector, v as SuiteFactory, h as SuiteHooks, T as Task, j as TaskBase, u as TaskCustomOptions, l as TaskMeta, m as TaskResult, i as TaskState, e as TestAPI, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-rsXe_qLO.js';
3
+ import { DiffOptions } from '@vitest/utils/diff';
3
4
  import '@vitest/utils';
4
5
 
5
- /**
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */
11
-
12
-
13
- declare type CompareKeys =
14
- | ((a: string, b: string) => number)
15
- | null
16
- | undefined;
17
-
18
- /**
19
- * Copyright (c) Meta Platforms, Inc. and affiliates.
20
- *
21
- * This source code is licensed under the MIT license found in the
22
- * LICENSE file in the root directory of this source tree.
23
- */
24
-
25
- type DiffOptionsColor = (arg: string) => string;
26
- interface DiffOptions {
27
- aAnnotation?: string;
28
- aColor?: DiffOptionsColor;
29
- aIndicator?: string;
30
- bAnnotation?: string;
31
- bColor?: DiffOptionsColor;
32
- bIndicator?: string;
33
- changeColor?: DiffOptionsColor;
34
- changeLineTrailingSpaceColor?: DiffOptionsColor;
35
- commonColor?: DiffOptionsColor;
36
- commonIndicator?: string;
37
- commonLineTrailingSpaceColor?: DiffOptionsColor;
38
- contextLines?: number;
39
- emptyFirstOrLastLinePlaceholder?: string;
40
- expand?: boolean;
41
- includeChangeCounts?: boolean;
42
- omitAnnotationLines?: boolean;
43
- patchColor?: DiffOptionsColor;
44
- compareKeys?: CompareKeys;
45
- }
46
-
47
6
  interface VitestRunnerConfig {
48
7
  root: string;
49
8
  setupFiles: string[] | string;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Suite, T as Task, a as Test, C as Custom } from './tasks-0309a91e.js';
2
- export { b as ChainableFunction, c as createChainable } from './tasks-0309a91e.js';
1
+ import { S as Suite, T as Task, a as Test, C as Custom } from './tasks-rsXe_qLO.js';
2
+ export { b as ChainableFunction, c as createChainable } from './tasks-rsXe_qLO.js';
3
3
  import { Arrayable } from '@vitest/utils';
4
4
 
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.4",
4
+ "version": "1.0.0-beta.6",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -18,15 +18,15 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
21
+ "default": "./dist/index.js"
22
22
  },
23
23
  "./utils": {
24
24
  "types": "./dist/utils.d.ts",
25
- "import": "./dist/utils.js"
25
+ "default": "./dist/utils.js"
26
26
  },
27
27
  "./types": {
28
28
  "types": "./dist/types.d.ts",
29
- "import": "./dist/types.js"
29
+ "default": "./dist/types.js"
30
30
  },
31
31
  "./*": "./*"
32
32
  },
@@ -34,13 +34,13 @@
34
34
  "module": "./dist/index.js",
35
35
  "types": "./dist/index.d.ts",
36
36
  "files": [
37
- "dist",
38
- "*.d.ts"
37
+ "*.d.ts",
38
+ "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "p-limit": "^4.0.0",
41
+ "p-limit": "^5.0.0",
42
42
  "pathe": "^1.1.1",
43
- "@vitest/utils": "1.0.0-beta.4"
43
+ "@vitest/utils": "1.0.0-beta.6"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "rimraf dist && rollup -c",